oobnuker
|
(Getting the hang of it)
|
2004-09-13 10:31 PM
|
|
|
|
|
Problem with @IPADDRESS0
|
|
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.
|
|
Re: Problem with @IPADDRESS0
|
|
What does "IPconfig /all" yield?
|
oobnuker
|
(Getting the hang of it)
|
2004-09-13 10:39 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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...
|
MightyR1
|
(MM club member)
|
2004-09-13 11:22 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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?
|
Les
|
(KiX Master)
|
2004-09-13 11:47 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
Write a separate scriptlet as follows and run it from a DOS prompt. Code:
break on '@@IPAddress0 = [' + @IPAddress0 + ']'?
Report back the output.
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
oobnuker
|
(Getting the hang of it)
|
2004-09-14 12:44 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
(Getting the hang of it)
|
2004-09-14 12:45 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
(Getting the hang of it)
|
2004-09-14 12:49 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
(Getting the hang of it)
|
2004-09-14 01:09 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
(Getting the hang of it)
|
2004-09-14 01:12 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
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...
|
|
Re: Problem with @IPADDRESS0
|
|
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
|
Les
|
(KiX Master)
|
2004-09-14 02:43 PM
|
|
|
|
|
Re: Problem with @IPADDRESS0
|
|
Quote:
I got no output.
That makes no sense that you would have absolutely no output. You should at the very least have: @IPAddress0 = []
|