Sunny4Ever
IS-IT--Management
Hi All
I am trying to use EnableDHCP method in WMI - I got this code sample from Microsoft:
strComputer = "."
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.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next
Wscript.Echo "Finished"
Which works perfectly, the problem I have is when I try and run this against a remote machine and replace the "."
The script does actually work and change a PC to DHCP enabled but it seems that this success is never returned to the script so any atempt to trap the return value will fail and the script just hangs .
Is this just a limitation of the EnableDHCP method or am I missing something???
Thanks,
Sunny
I am trying to use EnableDHCP method in WMI - I got this code sample from Microsoft:
strComputer = "."
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.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next
Wscript.Echo "Finished"
Which works perfectly, the problem I have is when I try and run this against a remote machine and replace the "."
The script does actually work and change a PC to DHCP enabled but it seems that this success is never returned to the script so any atempt to trap the return value will fail and the script just hangs .
Is this just a limitation of the EnableDHCP method or am I missing something???
Thanks,
Sunny