Clear IP Gateways 
Author Message
 Clear IP Gateways

Hello all

I tried to change the network adapter configuration with a script.
I couldn’t find a solution for removing all defined IP Gateways.

Okay I’m a VBScript and WMI greenhorn …

Could somebody give me a hint how I can solve this problem ?

Thanks in advance


Option Explicit

Const cComputerName="LocalHost"
Const cWMINameSpace="root\cimv2"
Const cWMIClass="Win32_NetworkAdapterConfiguration"
Const cWMIObjectName="3Com EtherLink XL 10/100 PCI TX NIC (3C905B-TX)"

Dim objWMIInstance, objWMIInstances
Dim varElememnt, varRC

Set objWMIInstances = GetObject("winmgmts:{impersonationLevel=impersonate}!//" &
cComputerName & "/" & cWMINameSpace).Instancesof(cWMIClass)

For Each objWMIInstance in objWMIInstances
        If Mid (objWMIInstance.Caption, 12) = cWMIObjectName Then

                'Clear Gateways
'               varRC = objWMIInstance.SetGateways(Array(""), Array
("1")) 'okay
'               varRC = objWMIInstance.SetGateways(Array("")) 'okay
'               varRC = objWMIInstance.SetGateways(Array("")) 'Error
'               varRC = objWMIInstance.SetGateways(Array("")) 'Error
'               varRC = objWMIInstance.SetGateways(Array(vbNUllString)) 'Error
                varRC = objWMIInstance.SetGateways(Array(vbNUllString), Array
("1")) 'Error
'               varRC = objWMIInstance.SetGateways(vbNullString) 'Type mismatch
'               varRC = objWMIInstance.SetGateways(0, 0) ' Type mismatch
'               varRC = objWMIInstance.SetGateways(Array(""), Array("")) 'Type
                If varRC Then
                        WScript.Echo varRC & ": Gateway Configuration ERROR!"
                        WScript.Echo varRC & ": Gateway Configuration successful!"
                End If
        End If

Set objWMIInstances = Nothing

Mon, 01 Sep 2003 00:02:37 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Changing IP/DNS/GATEWAY info on the fly in Win2k

2. Script for switching IP-adress and gateway

3. Changing IP/DNS/GATEWAY info on the fly in Win2k

4. Changing IP/DNS/GATEWAY info on the fly in Win2k

5. set gateway script in wxp and w2000

6. Change Gateway and DNS

7. Script to change gateway?

8. Epson Color Stylus/ Charon gateway/ Prints nonsense!

9. Ping a Gateway

10. Setting subnet mask a gateway with wsh

11. I want to get some info of IP Adress,netmask,gateway,opened ports...

12. Adding second gateway


Powered by phpBB® Forum Software