openvpn.config/CLIENT_DATA/set_2nd_ip.vbs

22 lines
1.0 KiB
Plaintext
Raw Normal View History

2012-05-07 21:34:39 +02:00
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
IParrData = Array("0.0.0.0", Wscript.Arguments(0))
SubnetarrData = Array("0.0.0.0", Wscript.Arguments(1))
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where NetConnectionStatus = 2 AND Name <> 'TAP-Win32 Adapter V9'",,48)
For Each objItem in colItems
Set colItems2 = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where index = "&objItem.index,,48)
For Each objItem2 in colItems2
strKeyPath = strKeyPath &"\"& objItem2.SettingID
objWMI.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,"IPAddress",IParrData
objWMI.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,"SubnetMask",SubnetarrData
next
Next