Page 1 of 1 1
Topic Options
#126642 - 2004-09-13 10:31 PM Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
I have a tiny little piece of code that I am trying to use that will post the IP Address to a registry key. I have another executable that polls that key and uses the value for other things. On many of my systems, for some reason, @IPADDRESS0 returns nothing. I have also tried 1-3 with no luck.

Here is the code:
Code:
 

$IPWRITE = WriteValue("HKEY_LOCAL_MACHINE\Software\Company","IPADDRESS","@IPADDRESS0","REG_SZ")



I have added an echo to see if it prints anything to the screen and on many systems I get nothing back for @IPADDRESS0.

Any ideas?

PS: Oh yeah - all systems are Windows 2000.


Edited by oobnuker (2004-09-13 10:33 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126643 - 2004-09-13 10:35 PM Re: Problem with @IPADDRESS0
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
What does "IPconfig /all" yield?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#126644 - 2004-09-13 10:39 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Without cutting and pasting - It looks like a normal output. On this particular machine that I am looking at there is only one NIC and everything looks good...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126645 - 2004-09-13 11:22 PM Re: Problem with @IPADDRESS0
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Strange,

just ran your line of code and got the entry in my register.

Is this your whole code or is it inside a script?
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#126646 - 2004-09-13 11:47 PM Re: Problem with @IPADDRESS0
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Write a separate scriptlet as follows and run it from a DOS prompt.
Code:
break on
'@@IPAddress0 = [' + @IPAddress0 + ']'?



Report back the output.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#126647 - 2004-09-14 09:40 AM Re: Problem with @IPADDRESS0
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You might as well check all of them, in case @IPADDRESS0 is consumed by a null or dial-up interface or something strange:
Code:

$=Execute("Exit 0")
'@@IPAddress0 = [' + @IPAddress0 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress1 = [' + @IPAddress1 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress2 = [' + @IPAddress2 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress3 = [' + @IPAddress3 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf


Top
#126648 - 2004-09-14 12:44 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Write a separate scriptlet as follows and run it from a DOS prompt.
Code:
break on
'@@IPAddress0 = [' + @IPAddress0 + ']'?



Report back the output.




I got no output. When I changed it to @IPADDRESS1 on this particular machine, the process hung...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126649 - 2004-09-14 12:45 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Strange,

just ran your line of code and got the entry in my register.

Is this your whole code or is it inside a script?




It's part of a login script, but it is in it's own separate space - and in my testing, I am running it stand alone.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126650 - 2004-09-14 12:49 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

You might as well check all of them, in case @IPADDRESS0 is consumed by a null or dial-up interface or something strange:
Code:

$=Execute("Exit 0")
'@@IPAddress0 = [' + @IPAddress0 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress1 = [' + @IPAddress1 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress2 = [' + @IPAddress2 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
'@@IPAddress3 = [' + @IPAddress3 + ']'?
If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf






Still nothing...Gah!
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126651 - 2004-09-14 01:09 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Here's a weird one. I thought I'd cheat a little and try something else. So I downloaded this: http://www.sysinternals.com/ntw2k/source/misc.shtml#hostname

You pass it the computer name and it returns an IP Address. On the systems that are not returning anything with the KIX script, I get an error saying "invalid IP Address".

Interesting...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126652 - 2004-09-14 01:12 PM Re: Problem with @IPADDRESS0
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Here's a weird one. I thought I'd cheat a little and try something else. So I downloaded this: http://www.sysinternals.com/ntw2k/source/misc.shtml#hostname

You pass it the computer name and it returns an IP Address. On the systems that are not returning anything with the KIX script, I get an error saying "invalid IP Address".

Interesting...




Hmmm...I added the full DNS suffix to the suspect machine and it appears to work.

Still no idea what is going on with the KIX @IPADDRESS0 issue...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#126653 - 2004-09-14 01:42 PM Re: Problem with @IPADDRESS0
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
How about using WMI to get the info?

You could get this info directly in your polling script rather that relying on this two-pass solution.

Here is an example - to get the info from another machine (providing you have sufficient privilege) just pass the machine name to the UDF as a parameter:

Code:
Break ON
$=SetOption("Explicit","ON")

Dim $sHost
Dim $sIPAddress, $asIPAddress

$sHost=@WKSTA

$asIPAddress=funGetIPAddress($sHost)
If @ERROR
"Could not retrieve IP addresses from '"+$sHost+"'"+@CRLF
"Error: ["+@ERROR+"] "+@SERROR+@CRLF
Else
For Each $sIPAddress in $asIPAddress
"IP Address found: " $sIPAddress ?
Next
EndIf

Function funGetIPAddress(Optional $sHost)
Dim $oWMI
Dim $colItems,$oItem
Dim $asIPAddress,$sIPAddress

If Not $sHost $sHost="." EndIf

$oWMI = GetObject("winmgmts:\\" + $sHost + "\root\cimv2")
If @ERROR Exit @ERROR EndIf
$colItems = $oWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
If @ERROR Exit @ERROR EndIf

For Each $oItem in $colItems
$asIPAddress = $oItem.IPAddress
For Each $sIPAddress in $asIPAddress
If $sIPAddress
Redim Preserve $funGetIPAddress[UBound($funGetIPAddress)+1]
$funGetIPAddress[UBound($funGetIPAddress)]=$sIPAddress
EndIf
Next
Next

Exit 0
EndFunction


Top
#126654 - 2004-09-14 02:43 PM Re: Problem with @IPADDRESS0
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I got no output.



That makes no sense that you would have absolutely no output. You should at the very least have:
@IPAddress0 = []
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.064 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org