
Getting Local IP address running a VBS script locally
Try this function that will eventually return your IP
(Ripped from msdn.microsoft.com sorry I cant remember the URL)
It may be corrupt as I didnt check it enough... =)
On Error Resume Next
WScript.Echo getcurip()
function getcurip()
sNic = regout("HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\NetworkCards\1\ServiceName")
'sMan = regout("HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\NetworkCards\1\Manufacturer")
sTcpipRegKey = "HKLM\SYSTEM\CurrentControlSet\Services\" & sNic &
"\Parameters\Tcpip\"
bIsDHCP = regout(sTcpipRegKey & "EnableDHCP")
If bIsDHCP Then
wscript.echo "DHCP-IP: " & regout(sTcpipRegKey & "DhcpIPAddress")
wscript.echo "IP: " & regout(sTcpipRegKey & "IPAddress")
getcurip = regout(sTcpipRegKey & "DhcpIPAddress")
wscript.echo "Error: "& Err.Number & Err.Description
Else
wscript.echo "IP: " & regout(sTcpipRegKey & "IPAddress")
getcurip = regout(sTcpipRegKey & "IPAddress")
wscript.echo "Error: "& Err.Number & Err.Description
End If
end Function
function regout(value)
Set regrespons = CreateObject("WScript.Shell")
regout=regrespons.RegRead(value)
end function
Quote:
> I am very new to VBS and I was wondering if I try running a .vbs script on
> my machine(Win98) how could I
> make it have a dialog box with my current IP address.
> Thanks,
> JJJ