Home » Questions » Computers [ Ask a new question ]

Enable/disable wireless interface in a bat file

Enable/disable wireless interface in a bat file

Is there a way to enable/disable a wireless network interface via the command line (so I can put it in a bat file)?

Asked by: Guest | Views: 18
Total answers/comments: 4
Guest [Entry]

"I'd like to set up a bat file or a
shortcut that I can use to
enable/disable the wireless

Use Microsoft DevCon ...

The DevCon utility is a
command-line utility that acts as an
alternative to Device Manager. Using
DevCon, you can enable, disable,
restart, update, remove, and query
individual devices or groups of
devices. DevCon also provides
information that is relevant to the
driver developer and is not available
in Device Manager.

And here's tutorial for you:

Enable/Disable Wireless Card from Command Line

preferably a single one that toggles
the current state

You'll need two batch files, one for WiFi Off and one for WiFi On.

Having said that, i assume you're using a laptop. Are you sure your Laptop doesn't allow to toggle WLAN on/off via a Fn key combo or a physical switch? Can you post make and model?"
Guest [Entry]

"I made a batch file for switching between LAN and WLAN. It enables your LAN connection and disables your WLAN connection if WLAN is active, and vice versa.

The batch file has been tested on Windows 7. Call it WLAN-LAN.bat and start it as an elevated prompt.

@Echo off

Echo De Netwerkinstellingen worden omgezet van WLan naar LAN of Vice Versa !
Echo Even Geduld svp .................................................

net start dot3svc
netsh lan show interfaces >NUL

if errorlevel 1 goto LAN
if errorlevel 0 goto WLAN

:LAN

netsh interface set interface ""Draadloze netwerkverbinding"" disabled >NUL

sc start dot3svc >NUL
netsh interface set interface ""LAN-verbinding"" enabled >NUL

goto end

:WLAN

sc start dot3svc >NUL
netsh interface set interface ""LAN-verbinding"" disabled >NUL
sc stop dot3svc >NUL

netsh interface set interface ""Draadloze netwerkverbinding"" enabled >NUL

:end

You should change the names of the network interfaces to match the network interfaces on your own system. So change the names between quotes: ""..."".

Further, should you set wired autoconfig service on automatic. The text in the comments can be changed as you wish."
Guest [Entry]

Another Possibility is Sikuli Script. Sikuli is really cool because it takes a visual approach to scripting, and should easily be able to accomplish what you need. Check out the video at the above link to see what I mean. Sikuli runs on Mac, Windows, and Linux.
Guest [Entry]

"It may be possible using the wmic utility (although I'm not sure if it comes with Windows Vista/7/etc.)

or

(though this is a funny way to do it and may break stuff, and it may not work so well) use the netsh tool (also it might not come with the new Windows versions) to give the network adapter a manually-assigned IP address if it is supposed to have a auto-assigned one, or the other way around."