Включение DHCP клиента
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
или
Option Explicit 'On Error Resume Next dim qQuery dim oConnection dim oCommand dim oRecordSet Dim oDom Dim oProvider Dim oOU Dim Target, oWMIService, colNetAdapters, oNetAdapter, errEnable oProvider = "'LDAP://" oDom = "dc=nwtraders, dc=msft'" oOU = "ou=workstations," qQuery = "Select Name from " & oProvider _ & oOU & oDom & "where objectClass='computer'" Set oConnection = CreateObject("ADODB.Connection") Set oCommand = CreateObject("ADODB.Command") oConnection.Open "Provider=ADsDSOObject;" oCommand.ActiveConnection = oConnection oCommand.CommandText = qQuery Set oRecordSet = oCommand.Execute While Not oRecordSet.EOF Target= oRecordSet.Fields("name") Set oWMIService = GetObject("winmgmts:\\" & Target & "\root\cimv2") Set colNetAdapters = oWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each oNetAdapter In colNetAdapters errEnable = oNetAdapter.EnableDHCP() If errEnable = 0 Then Wscript.Echo "DHCP has been enabled." Else Wscript.Echo "DHCP could not be enabled." End If Next oRecordSet.MoveNext Wend oConnection.Close
Интересное на сайте:
Голосов пока нет
Оставить комментарий