Chapter 9. Command Prompt and Automation

Many seasoned computer users find it a comfort and a relief to abandon the GUI in favor of a good ol’ command prompt. This isn’t nostalgia, but merely an admission that the Windows GUI doesn’t solve all our problems. After all these years, it’s still faster and easier to rename groups of files with the ren command than by pointing and clicking.

The Command Prompt in Windows 7 is loosely based on MS-DOS (Microsoft Disk Operating System), the operating system used by the first PCs and the basis for many versions of Windows, including 95 and 98, up to Windows Me. Although Windows 7 is long since divorced from its arcane C-prompt ancestry, you’ll find many hacks in this book that rely on tools only accessible via the little blinking cursor in the plain black box.

Windows 7 also comes with PowerShell—also known as MSH, or the Monad Shell—which is more or less a geek-centric replacement for the Command Prompt.

But where command-line interfaces shine is their ability to play back sequences of commands called scripts. One of the carry-overs from DOS is the lowly batch file, a rudimentary means of scripting DOS commands. Windows 7 also includes the Windows Script Host (WSH), which can run simple programs written in VBScript or Jscript, or with add-ons, many other languages. (WSH scripts are beyond the scope of this book.) Not to be left out, PowerShell scripts are more powerful than batch files; in some cases, even a single line entered by hand at the ...

Get Windows 7 Annoyances now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.