oto skrypt:
On Error Resume Next
Set objWMIService = GetObject("winmgmts:")
'Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
' If the office uses DHCP, call SetDHCP.
SetDHCP
'******************************************************************************
Sub SetDHCP
For Each objNicConfig In colNicConfigs
'WScript.Echo VbCrLf & "Network Adapter " & objNicConfig.Index & _
'VbCrLf & " " & objNicConfig.Description & VbCrLf
If Not objNicConfig.DHCPEnabled Then
intReturn = objNicConfig.EnableDHCP
'If intReturn = 0 Then
'WScript.Echo " DHCP enabled."
'Else
'WScript.Echo " Unable to enable DHCP." & " Error #:" & intReturn
'End If
intDNS = objNicConfig.SetDNSServerSearchOrder(null)
Err.Clear
'Else
'WScript.Echo " DHCP already enabled" & VbCrLf & _
'" DHCP Server: " & objNicConfig.DHCPServer
Err.Clear
End If
Next
End Sub
--
Darek (DAKOTA)
> Witam
> Mam skrypt vbs ktory automatycznie zamienia mi ustawienia karty sieciowej na
> dhcp, na xp wszystko dziala oki, ale mam problem z win 2000
> Otóż w 2000 skrypt ten prawidłowo ustawia karte sieciowa na dhcp, ale jezeli
> dam ipconfig /all to pokazuje on jako defaultgateway stary statyczny wpis,
> pomimo ze faktycznie system juz korzysta z gatewaya ustawianego przez dhcp.
> Przejżałem rejestr i wisi tam faktycznie w kluczu DefaultGateway stary ipek.
> Jak zmodyfikować ten skrypt aby mi usuwał ten wpis z rejestru?
>
> oto skrypt:
'WScript.Echo VbCrLf & "Network Adapter " & objNicConfig.Index & _
'VbCrLf & " " & objNicConfig.Description & VbCrLf
If Not objNicConfig.DHCPEnabled Then
intReturn = objNicConfig.EnableDHCP
'If intReturn = 0 Then 'WScript.Echo " DHCP enabled."
release = "ipconfig /release"
renew = "ipconfig /renew"
gw = shell.run (release,0,true)
gw = shell.run (renew,0,true)
'Else
--
M. [Windows - Shell/User MVP]
/odpowiadając na priv zmień px na pl/
https://mvp.support.microsoft.com/profile/Michal.Kawecki