The Microsoft Windows 2000 Server Resource Kit, Win2K Support Tools, and Microsoft Windows NT Server 4.0 Resource Kit are primary resources for tools that you can use at the command line and in command shell scripts. Although these resources offer an extensive set of command-line utilities, eventually you'll probably want to use other tools. Fortunately, many developers offer command-line tools on the Internet at little or no cost. Here's a look at just a few of the resources available.
Bill Buckels offers CommandLine Commando, a freeware package of filters and utilities for Win2K, NT, and Windows 9x systems. This package contains 17 filters (i.e., programs that transform standard input in some way and write the output to the standard output device). The filters include Decho (which echoes standard input to the screen and is great for debugging scripts), Dict (which places each word in a file on a separate line), Pad (which pads each line in a file to a fixed length), and Uniq (which deletes multiple occurrences from a sorted list).
In addition to the filters, CommandLine Commando contains 19 utilities. Some of these utilities help fill the command shell's void in string-filtering functions. For example, the Bingrep and Igrep utilities perform text searches in binary and text files, respectively. The Idiff utility compares two text files and reports the differences. The other utilities perform a variety of functions. For example, the Whereis utility searches the hard disk for specified files and the Txt2pcx utility converts ASCII text to monochrome .pcx images. The Longtext utility removes Word Wrap from text files (i.e., converts DOS text to Windows text), whereas Wraptext adds Word Wrap to text files (i.e., converts Windows text to DOS text).
For descriptions of all the filters and utilities in CommandLine Commando, go to http://www.escape.ca/~bbuckels/cprog.htm, click Program Descriptions, then click The CommandLine Commando User's Manual.
Nigel Lark offers several Novell NetWare and DOS-batch utilities as freeware on the Krillagen Web site (http://www.krillagen.com). One of the DOS-batch utilities—FOREACH—is quite useful for Win2K and NT scripting. This command-line utility offers functions similar to those the For command offers but with additional control. If you regularly execute commands that use data from input files, you can use FOREACH to increase your scripts' capabilities. (Because FOREACH runs as a DOS-mode command, long filenames might not work properly.)
Bill Chaison (http://www.geocities.com/researchtriangle/facility/6201) has developed several NT-compatible utilities that capture performance data. You can even log that data directly to a Comma Separated Value (CSV) file. The utilities are part of a fairware package called Performance Tools. (Fairware is software for which payment is voluntary. Chaison suggests a voluntary contribution of $10 for this package.) Performance Tools includes the following utilities:
- ProcInfo—captures process data, such as a process's name, process identifier (PID), and number of threads
- MemInfo—obtains memory data, such as available physical memory (in bytes) and the amount of physical memory allocated to the file and network cache
- SysInfo—provides system data, such as uptime and the number of threads in the thread queue
- DiskInfo—acquires data about physical and logical disks, including the total percent of time a device was reading and writing data during the test period
- ServInfo—captures data specific to file servers, such as the number of open files and the number of failed attempts to access the file system
- ATCPInfo—provides TCP/IP statistics at the adapter level, including the adapter's maximum data rate and the number of packets sent and received per second
- PageInfo—displays virtual memory statistics for a system, such as the amount of total and in-use virtual memory
- GetDate—returns the day of the week
- Suspend—prompts a sleep cycle
Kilowatt Software has a large command-line utility package called Poof! Although this package costs only $15.95, it includes more than 135 utilities. The utilities fall into 10 categories:
- Batch script aids—utilities you use within batch scripts (e.g., QUERY, which displays a Yes or No prompt within a message window)
- Binary file—utilities you use to work with binary files (e.g., ASC_ONLY, which extracts ASCII characters from binary files)
- Clipboard—utilities you use to interact with the system clipboard (e.g., CLIPPATH, which adds a file's directory path to the system clipboard)
- Command launching—utilities you use to run nested commands (e.g., REPEATN, which performs a command multiple times)
- File management—utilities you use to manage files (e.g., RO, which converts files to read-only files)
- HTML preparation—utilities you use to create .htm files (e.g., CSV2HTML, which converts CSV files to Web pages)
- Math and conversion—utilities you use to perform math and conversion functions (e.g., X2D, which converts hexadecimal values to their decimal equivalents)
- Software development—utilities you use to develop software (e.g., GARNER, which gathers special remarks from program source files for conversion to HTML)
- Text file content aids—utilities you use to work with various types of text files, such as plaintext and CSV files (e.g., BUNDLE, which compiles multiple text files into one bundle file)
- Miscellaneous—utilities with varied purposes (e.g., ARGS, which shows command arguments)
For the complete list of utilities, go to http://www.kilowattsoftware.com, then click Poof!
Sysinternals (http://www.sysinternals.com) offers a free suite of W2K- and NT-compatible utilities called PsTools. This suite provides 10 utilities:
- PsExec—runs programs on remote computers
- PsFile—displays open files on remote computers and closes files
- PsGetSid—obtains computers' and users' SIDs
- PsKill—terminates a specified process (which the process name or PID identifies) running on a local or remote computer
- PsList—obtains detailed CPU, memory, and thread information about processes running on local and remote computers
- PsLoggedOn—identifies logged-on users on local and remote computers
- PsLogList—displays and clears the contents of event logs on local and remote computers
- PsService—displays data about services on local and remote computers (e.g., service status, service dependencies) and controls those services (e.g., starts or stops services)
- PsShutdown—shuts down and reboots local and remote computers
- PsUptime—specifies how long the local or specified computer has been running
Steve Seguis at Script Horizon (http://www.scripthorizon.com) offers several freeware GUI utilities. His Run Hidden (runh.exe) utility is especially helpful because it lets you launch scripts or programs in background mode. Background mode is ideal if you want to run a batch file but don't want users to see it run or to accidentally cancel it. Run Hidden is also ideal if you schedule scripts with Task Scheduler but dislike the script windows that pop up and interrupt your work when the scripts execute.
Smaller Animals Software (http://www.smalleranimals.com) offers SASuite, a suite of command-line utilities that manipulate image files. This suite is ideal for bulk manipulations of images. The suite costs $30 and includes the following utilities:
- SAAtoCrp—automatically crops the edges of images
- SABlur—blurs images
- SACrop—crops images
- SADims—obtains images' dimensions
- SAFlip—flips images horizontally or vertically
- SAMatte—places images on a solid background
- SAOvrlay—overlays one image onto another image
- SARot90—rotates images 90 degrees
- SARotate—rotates images by the angle you specify
- SASharp—sharpens images
- SASize—resizes images
- SAText—draws text onto images
In addition, Smaller Animals Software offers freeware. One of my favorite freeware utilities is SAMenu. This Windows Explorer extension lets you copy paths to the clipboard so that you can quickly capture and paste file and folder paths into scripts. You can also use this utility for other tasks, such as renaming files and changing file permissions. Another freeware utility is DirCase, which lets you change filenames to uppercase or lowercase.
More Internet Resources
The utilities and filters I mention in this article are just a few command-line tools that are available. If you search for command-line utilities on the Internet, you'll probably find many more tools that you'll want to check out.
The wealth of command-line tools on the market is an indication that the command line is alive and well. More administrators are recognizing the power of shell scripting at the command line and in command scripts.