Hi everyone,
Just need to make a script that sets the computer from DHCP to a static IP so far I have this it gives me the error errEnable, or is there an easier way??????
P.S. I define all of the IP settings also,
Thanks,
Ross
***********************************
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway)
errDNSServers = objNetAdapter.SetDNSServerSearchOrder(strDNSServers)
If errEnable = 0 Then
WScript.Echo "Static IP addressing now configured for "&strComputer
Else
WScript.Echo "Static IP addressing could not be configured."
End If
Next
set strIPAddress = nothing
set strSubnetMask = nothing
set strGateway = nothing
set strComputer = nothing
wscript.quit
Just need to make a script that sets the computer from DHCP to a static IP so far I have this it gives me the error errEnable, or is there an easier way??????
P.S. I define all of the IP settings also,
Thanks,
Ross
***********************************
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway)
errDNSServers = objNetAdapter.SetDNSServerSearchOrder(strDNSServers)
If errEnable = 0 Then
WScript.Echo "Static IP addressing now configured for "&strComputer
Else
WScript.Echo "Static IP addressing could not be configured."
End If
Next
set strIPAddress = nothing
set strSubnetMask = nothing
set strGateway = nothing
set strComputer = nothing
wscript.quit