'Script Start
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled = true")
goDHCP()
Sub goDHCP()
For Each objItem In colItems
errEnable = objItem.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Msgbox "setting DNS"
errDNS = objitem.SetDNSServerSearchOrder()
errDDNS = objItem.SetDynamicDNSRegistration
msgbox "DNS Set"
errRenew = objItem.RenewDHCPLease
msgbox "renew called"
If errRenew = 0 Then
Wscript.Echo "DHCP lease renewed."
Else
Wscript.Echo "DHCP lease could not be renewed." & err.number & err.description
End If
Next
End Sub
'Script End
Got from website www.vittorio.tk
How to execute a VBScript
No comments:
Post a Comment