Command line scripts
To store the scripts that I use from the command line, I create the Command Line Scripts in the Program Files section and add it to the PATH environment variable. I use the following batch file to list and edit these scripts:
@echo off setlocal set UTILPATH=C:\Program Files\System Tools\Command Line Utilities if not "x%1"=="x" ( start "" "notepad" "%UTILPATH%\%1.bat" ) else ( dir /b "%UTILPATH%" | grep -v com.bat | grep -P "(exe|bat|cmd)" | sed "s/\.\(exe\|bat\|cmd\)//" echo. )
(note that filtering the directory list depends on some unix commands that I installed through Cygwin )
I give it the name com.bat (short for the command), then I can:
- list the scripts in this directory by typing
com at the command prompt - edit any script in the list by typing
com script-name at the command line *, similarly: - create new scripts in this directory by typing
com new-script-name at the command line * - and if I ever need to edit com.bat, I just type
com com
* When I start Vista, I need to use the elevated command prompt, since the directories under Program Files are protected. To quickly launch the extended command line, just click the Win key button; type cmd ; press Ctrl+Shift+Enter ; and then press Alt+C to confirm the height request. Six keystrokes on the command line with elevated privileges! ([Via] [4])
Script commissioning
One of the scripts stored in my Command Line Scripts directory is a script that runs when you log in to Windows (through Task Scheduler , type Task in the Vista Start menu). I use this script to configure multiple virtual disks using the subst command for directories that I often access or want a quick way to access on the command line or to shorten path names in compiler warnings, logs or debug output.
My script run looks something like this:
@setlocal @set _MYDOCS_=%USERPROFILE%\Documents @REM Note: first delete the drives so I can run script again @REM to fix drives that failed to get mapped subst /d W: subst /d T: subst /d S: subst /d R: subst /d N: subst /d L: subst /d H: subst W: "%_MYDOCS_%\Work\SVN Working Copy\Website\trunk\www" subst T: "%_MYDOCS_%\Work\SVN Working Copy\project 1\trunk" subst S: "%_MYDOCS_%\Work\SVN Working Copy" subst R: "%_MYDOCS_%\Work\SVN Working Copy\project 2\branches\12.50" subst N: "%_MYDOCS_%\Work\SVN Working Copy\project 2\trunk" subst L: "%_MYDOCS_%\Work\" subst H: "%_MYDOCS_%\My Projects\Haslers.info\Working Copy"
Note that subst can be a bit temperamental, and sometimes disks are not created, and I have to start the script manually again.
Sam Hasler Dec 05 '08 at 18:42 2008-12-05 18:42
source share