0ren
asked on
disable network connection using script
i have a WIN2K server with 2 ethernet cards. each card is in a different subnet
one is connected to the internet and the other is connected to the intranet.
i need a script that will close one and open the other and vice versa so both
cards will never be connected at the same time. ( disable routing is not an option )
the script will run by the scheduler or manualy.
one is connected to the internet and the other is connected to the intranet.
i need a script that will close one and open the other and vice versa so both
cards will never be connected at the same time. ( disable routing is not an option )
the script will run by the scheduler or manualy.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it works great but i have a minor problem.
when running devcon hwids i get the following:
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02\3 &1070020&0 &08
Name: Compaq NC7781 Gigabit Server Adapter
Hardware ID's:
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1
PCI\VEN_14E4&DEV_16A7&CC_0 20000
PCI\VEN_14E4&DEV_16A7&CC_0 200
Compatible ID's:
PCI\VEN_14E4&DEV_16A7&REV_ 02
PCI\VEN_14E4&DEV_16A7
PCI\VEN_14E4&CC_020000
PCI\VEN_14E4&CC_0200
PCI\VEN_14E4
PCI\CC_020000
PCI\CC_0200
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02\3 &1070020&0 &10
Name: Compaq NC7781 Gigabit Server Adapter #2
Hardware ID's:
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1
PCI\VEN_14E4&DEV_16A7&CC_0 20000
PCI\VEN_14E4&DEV_16A7&CC_0 200
Compatible ID's:
PCI\VEN_14E4&DEV_16A7&REV_ 02
PCI\VEN_14E4&DEV_16A7
PCI\VEN_14E4&CC_020000
PCI\VEN_14E4&CC_0200
PCI\VEN_14E4
PCI\CC_020000
PCI\CC_0200
the only lines that differ are those
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02\3 &1070020&0 &10
PCI\VEN_14E4&DEV_16A7&SUBS YS_00CB0E1 1&REV_02\3 &1070020&0 &08
if i will run for example devcon disable *DEV_16A7*
i will disable both cards.
how can run the devcon command on only one of the card?
when running devcon hwids i get the following:
PCI\VEN_14E4&DEV_16A7&SUBS
Name: Compaq NC7781 Gigabit Server Adapter
Hardware ID's:
PCI\VEN_14E4&DEV_16A7&SUBS
PCI\VEN_14E4&DEV_16A7&SUBS
PCI\VEN_14E4&DEV_16A7&CC_0
PCI\VEN_14E4&DEV_16A7&CC_0
Compatible ID's:
PCI\VEN_14E4&DEV_16A7&REV_
PCI\VEN_14E4&DEV_16A7
PCI\VEN_14E4&CC_020000
PCI\VEN_14E4&CC_0200
PCI\VEN_14E4
PCI\CC_020000
PCI\CC_0200
PCI\VEN_14E4&DEV_16A7&SUBS
Name: Compaq NC7781 Gigabit Server Adapter #2
Hardware ID's:
PCI\VEN_14E4&DEV_16A7&SUBS
PCI\VEN_14E4&DEV_16A7&SUBS
PCI\VEN_14E4&DEV_16A7&CC_0
PCI\VEN_14E4&DEV_16A7&CC_0
Compatible ID's:
PCI\VEN_14E4&DEV_16A7&REV_
PCI\VEN_14E4&DEV_16A7
PCI\VEN_14E4&CC_020000
PCI\VEN_14E4&CC_0200
PCI\VEN_14E4
PCI\CC_020000
PCI\CC_0200
the only lines that differ are those
PCI\VEN_14E4&DEV_16A7&SUBS
PCI\VEN_14E4&DEV_16A7&SUBS
if i will run for example devcon disable *DEV_16A7*
i will disable both cards.
how can run the devcon command on only one of the card?
devcon disable @*3*1070020*0*08
That should disable only the second card.
Example:
C:\test\i386>devcon.exe disable @*3*61AAA01*0*48
PCI\VEN_8086&DEV_1229&SUBS YS_0040808 6&REV_0C\3 &61AAA01&0 &48 : Disabled
1 device(s) disabled.
C:\test\i386>devcon.exe enable @*3*61AAA01*0*48
PCI\VEN_8086&DEV_1229&SUBS YS_0040808 6&REV_0C\3 &61AAA01&0 &48 : Enabled
1 device(s) enabled.
Why this works:
@ prefixes instance ID
* is the ideal replacement for & in the search string, being that cmd.exe interprets the ampersand as a second DOS command.
That should disable only the second card.
Example:
C:\test\i386>devcon.exe disable @*3*61AAA01*0*48
PCI\VEN_8086&DEV_1229&SUBS
1 device(s) disabled.
C:\test\i386>devcon.exe enable @*3*61AAA01*0*48
PCI\VEN_8086&DEV_1229&SUBS
1 device(s) enabled.
Why this works:
@ prefixes instance ID
* is the ideal replacement for & in the search string, being that cmd.exe interprets the ampersand as a second DOS command.
ASKER
it works like charm
thank you very much
thank you very much
##shutdown_eth.bat
##script to shut down an ethernet card ##
@echo off
ipconfig /release "Local Area Connection 2"
##startup_eth.bat
##script to start up an ethernet card ##
@echo off
ipconfig /renew "Local Area Connection 2"