views:

85

answers:

1

for example, if I want to stop "lan connection 1" in my control pannel, I usually right click it in my control panel and disable it. Now I want to write a script to disable and enable those connections. How can I do it??

Thank you very much

A: 

I googled for you:

netsh interface set interface name="Local Area Connection" admin=disabled

put your connection name in place of "Local Area Connection".


More detailed syntax of netsh:

Usage set interface [name = ] IfName

         [ [admin = ] ENABLED|DISABLED
           [connect = ] CONNECTED|DISCONNECTED
           [newname = ] NewName ]

  Sets interface parameters.

  IfName  - the name of the interface
  admin   - whether the interface should be enabled (non-LAN only).
  connect - whether to connect the interface (non-LAN only).
  newname - new name for the interface (LAN only).

  Notes:
  - At least one option other than the name must be specified.
  - If connect = CONNECTED is specified, then the interface
    is automatically enabled even if the admin = DISABLED
    option is specified.
pajton
Hi, thanks for your reply.I followed your instraction, but I got the folliwng error message:The synta supplied for this command is not valid. Check help for the correct syntax.....
Might be a minor syntax error. I read that `netsh` syntax varies a little between different versions of Windows. Try `netsh /?` maybe this is little syntax difference.
pajton