I hate to admit on a Unix admin type Blog that I have been recently forced to work in the Windows OS world.
Thankfully I have been able to place Cygwin on most of the systems that I support.
I have, however, needed to be able to create a few batch files that would run on a scheduled basis for various things and had to learn the tricks of the trade for working in the DOS command prompt.
Personal Cheat Sheet.
: — (followed by a space), alternative for “rem”, starts a comment
^ — line continuation… like a backslash (\) at the end of the line in unix
& — command separator (cmd1& cmd2& cmd3), like “;” in unix
&& — only execute the next statement if the last one succeeded, like unix/perl
|| — only execute the next statement if the last one failed, like unix/perl
- Passing in command line variables/parameters
Batch files can only handle parameters %0 to %9, ie cmd.bat Foo Bar where in the cmd.bat Foo=%1 and Bar = %2
- For Loops
- FOR %A IN (list) DO command [ parameters ]
I did find this web site has tons of useful information on windows scripts. The menu at the left will expand to show more info on each topic. Finding system uptime * net statistics server Listing all of your systems drivers* DRIVERQUERY /V /FO CSV > %ComputerName%.csv
