Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

skrypt dhcp , problem default gateway

22 views
Skip to first unread message

thim

unread,
Jan 2, 2008, 6:19:17 AM1/2/08
to
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:


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


Dariusz Kiszkiel

unread,
Jan 3, 2008, 6:31:52 PM1/3/08
to
"thim" <thim...@gazeta.pl> wrote in message
news:flfrrp$83d$1...@inews.gazeta.pl...

> Jak zmodyfikować ten skrypt aby mi
> usuwał ten wpis z rejestru?:
http://www.microsoft.com/technet/scriptcenter/scripts/os/registry/default.mspx

--
Darek (DAKOTA)


Michal Kawecki

unread,
Jan 4, 2008, 4:16:39 PM1/4/08
to
Dnia Wed, 2 Jan 2008 12:19:17 +0100, thim napisał(a):

> 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

0 new messages