Link to home
Start Free TrialLog in
Avatar of 0ren
0renFlag for Israel

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.
Avatar of Ray2003
Ray2003

You can write a .bat file which will disable one ethernet card with the commando ipcondig. For example:

##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"
ASKER CERTIFIED SOLUTION
Avatar of bkoehler-mpr
bkoehler-mpr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 0ren

ASKER

it works great but i have a minor problem.
when running devcon hwids i get the following:
PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11&REV_02\3&1070020&0&08
    Name: Compaq NC7781 Gigabit Server Adapter
    Hardware ID's:
        PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11&REV_02
        PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11
        PCI\VEN_14E4&DEV_16A7&CC_020000
        PCI\VEN_14E4&DEV_16A7&CC_0200
    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&SUBSYS_00CB0E11&REV_02\3&1070020&0&10
    Name: Compaq NC7781 Gigabit Server Adapter #2
    Hardware ID's:
        PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11&REV_02
        PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11
        PCI\VEN_14E4&DEV_16A7&CC_020000
        PCI\VEN_14E4&DEV_16A7&CC_0200
    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&SUBSYS_00CB0E11&REV_02\3&1070020&0&10
PCI\VEN_14E4&DEV_16A7&SUBSYS_00CB0E11&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?

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&SUBSYS_00408086&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&SUBSYS_00408086&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.
Avatar of 0ren

ASKER

it works like charm
thank you very much