Enable / Disable LAN

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Enable / Disable LAN

#1 Post by drgt » 19 Mar 2017 06:28

I tried to use

Code: Select all

netsh interface set interface "Local Area Connection" DISABLED

but I get
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct syntax.


Please help me with the correct syntax.

xp sp2

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enable / Disable LAN

#2 Post by ShadowThief » 19 Mar 2017 08:34

It may be expecting you to explicitly name the parameters.

Code: Select all

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


It's also possible that you don't have an interface called "Local Area Connection." You may want to run

Code: Select all

netsh interface show interface

to see what your options are.

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: Enable / Disable LAN

#3 Post by drgt » 19 Mar 2017 13:51

Code: Select all

netsh interface show interface


Admin State State Type Interface Name
-----------------------------------------------------------------------
Enabled Dedicated Local Area Connection 9
Enabled Dedicated Local Area Connection 3
Enabled Dedicated Local Area Connection
Enabled Internal Internal
Enabled Loopback Loopback


Code: Select all

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


One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct syntax.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enable / Disable LAN

#4 Post by ShadowThief » 19 Mar 2017 14:18

Weird, that should totally work. And

Code: Select all

netsh interface set interface /?
doesn't give any additional information about what it's expecting?

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: Enable / Disable LAN

#5 Post by drgt » 19 Mar 2017 14:21

The syntax supplied for this command is not valid. Check help for the correct syntax.

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.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enable / Disable LAN

#6 Post by ShadowThief » 19 Mar 2017 14:32

You're typing this instead of running it from a script? And you're not obfuscating the LAN name on here for some reason?

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: Enable / Disable LAN

#7 Post by drgt » 19 Mar 2017 14:41

I am giving this command in command prompt window. Yes I type it in (or I paste it in).

Those are the exact names as they appear.

I changed the name to Local_Area_Connection and tried it again with and without quotes.

Same thing!

Weird indeed.

*plus I do not know what local area connections 3 and 9 are!


EDIT: What is "non-LAN only" in (admin - whether the interface should be enabled (non-LAN only))?

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enable / Disable LAN

#8 Post by ShadowThief » 19 Mar 2017 14:48

Google says that netsh doesn't actually work in XP and you need to use DevCon. https://msdn.microsoft.com/windows/hard ... est/devcon

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: Enable / Disable LAN

#9 Post by drgt » 19 Mar 2017 15:10

Thanks!
wouldn't you happen to know its Syntax?

EDIT: This http://ccm.net/faq/1886-enable-disable- ... mmand-line explains it.

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: Enable / Disable LAN

#10 Post by drgt » 20 Mar 2017 02:57

Suppose I want to edit a desktop shortcut to execute a devcon command before, I simply create a batch file that includes both the devcon command and the shortcut code OR there is a better way?

Post Reply