Get host IP-adress?
Hi there!
I have a (wierd) application that needs to put the machines IP-adress in the registry.
Does anyone have any suggestions how to do this best?
I have been thinking about making a VBS to get the IP, but then I need to get the variable as a InstallShield String.
Isn't there any better way to do this?
Thanks!
/Jonas
I have a (wierd) application that needs to put the machines IP-adress in the registry.
Does anyone have any suggestions how to do this best?
I have been thinking about making a VBS to get the IP, but then I need to get the variable as a InstallShield String.
Isn't there any better way to do this?
Thanks!
/Jonas
0 Comments
[ + ] Show comments
Answers (5)
Please log in to answer
Posted by:
jonasm
18 years ago
I solved it with this VBS, but there must be a better way...
The HOSTIP is the propery that I uses where to set the IP-adress.
/Jonas
[hr]
Set objWMIService = GetObject("winmgmts:")
Set colNicConfig = objWMIService.ExecQuery("SELECT * FROM " & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfig
For Each strIPAddress In objNicConfig.IPAddress
'Only get IP-adress if it starts with "10."
If left(strIPAddress,3) = "10." Then
Session.Property("HOSTIP") = strIPAddress
End If
Next
Next
The HOSTIP is the propery that I uses where to set the IP-adress.
/Jonas
[hr]
Set objWMIService = GetObject("winmgmts:")
Set colNicConfig = objWMIService.ExecQuery("SELECT * FROM " & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfig
For Each strIPAddress In objNicConfig.IPAddress
'Only get IP-adress if it starts with "10."
If left(strIPAddress,3) = "10." Then
Session.Property("HOSTIP") = strIPAddress
End If
Next
Next
Posted by:
Secondlaw
18 years ago
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
________________________________________________
That script was generated with, "The Portable Script Center" (Free download) (http://www.microsoft.com/technet/scriptcenter)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
________________________________________________
That script was generated with, "The Portable Script Center" (Free download) (http://www.microsoft.com/technet/scriptcenter)
Posted by:
jonasm
18 years ago
Posted by:
Secondlaw
18 years ago
Posted by:
jmcfadyen
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.