3.12.07

Nerd Corner: Command Scripts

a month ago, i decided to stop using Intel's Wireless Utility that was provided with my computer; it required a lot of processes and tended to be wonky when hopping onto different networks. the built-in Windows utility for managing wireless networks is adequate. as a result, i can no longer use any hardware controls for the wireless card (the Z63 has buttons on the side for things like bluetooth, wireless, touchpad, etc). i also cannot use the keyboard shortcut (Fn+F2) to toggle the wireless card on and off. normally, when i run on battery (taking notes in class), i like to have the wireless card turned off to save power and to prevent my attention from wandering to the internets.

without the hardware toggle or the keyboard toggle, the 'simple' way to turn off the card would be to right-click the wireless icon and disable the card. the round-about route would be to open up the Device Manager and disable the card from there. both options suck. once the card is disabled, the icon no longer shows up in the System Tray and you have to drill into Network Connections to enable it from there. i could have written an essay in that time.

what i wanted was a shortcut to the program that controlled the wireless service so that i could just use Launchy to enable/disable the wireless card. unfortunately, no such Windows program, .exe, .dll or .bat file exists.

time for research. so i googled up two sites that each did half of what i wanted.
the first directed me to a neat utility Microsoft has: DevCon, a command line version of the Device Manager. using DevCon, i am now able to execute enable/disable commands to any hardware device on this computer, provided that i know the hardware ID. the site provided details on how to determine the IDs and how to use them in the command line.

ex. typing in "devcon disable *DEV_4220*" into the command prompt will turn off my wireless card. replacing "disable" with "enable" will turn it back on. this is still a handful to type each time.

as it turns out, command-line commands can be written as a .cmd file, essentially a pice of programming script that runs as if you typed the commands into the prompt. so the second site gave an example of just such a script. i modified it for my computer.

;Disable Wireless.cmd
;
@echo off
echo Disabling wireless card...
devcon disable *DEV_4220*
echo Done.
echo " " is just asking the command-line interface for feedback, indicating where in the program it currently is. ; " " are comments and not read by the compiler.

i saved this file (and the enable version) as .cmd files, placed them somewhere safe and created shortcut in my shortcuts folder for Launchy to index.

after some time of gloating and feeling proud of myself, i wondered what else i could script to make life easier...

sometimes, the wireless connection is spotty due to the router being unable to establish an IP address or somesuch wireless networking mumbo-jumbo. i normally fix that by going into the command prompt and typing:
ipconfig /release
ipconfig /renew
this does exactly the same thing that clicking Repair on your wireless connection does. armed with new knowledge, i decided it was time i stopped typing it all out by hand like a sucker.
;Repair Wireless Connection.cmd
;
@echo off
echo Releasing IP Address...
ipconfig /release
echo Renewing IP Address...
ipconfig /renew
echo Done.
i saved this script, shortcutted it as well.

i feel like a winner.

No comments:

  © Blogger template The Professional Template by Ourblogtemplates.com

Back to TOP