Vista Command-Line Tools
Use these tools to mirror directories, manage ACLs, perform backups, and complete other important administrative functions
April 27, 2008
The lion’s share of the attention to Windows Vistaalways seems to center around the new interface,which is understandable considering its excitingnew look and feel. Unfortunately, part of the attention isbecause you now have to find new ways of doing old tasks.However, new features in Vista don’t end with the UI.Under the covers, Vista also sports command-line tools—many of them new—that make a powerful addition toyour administrative toolbox. Here are my favorites.
10. Bcdedit—The days of editing the simpleboot.ini file are gone. Vista’s new bootprocess saves its system boot configurationin the Boot Configuration Data(BCD) store. Like all bad ideas, the BCD store replaces asimple concept with a complex albeit more secure one.Bcdedit is your primary tool for editing the BCD store.Bcdedit supports a wide set of command-line options.For instance, to list the contents of the store you can run
bcdedit /enum
9. Choice—A handy batch-file command, choicelets you display a list of choices to users of acommand-shell script. The choice commandreturns an index value in the ERRORLEVELenvironment variable indicating the user’s selection. Forexample, the following command prompts users to enterY, N, or C; the ERRORLEVEL variable returns 1, 2, or 3respectively:
CHOICE /C YNC /M “Press Y, N, or C.”
8. Waitfor—The waitfor command is a usefulscripting command that synchronizes processesrunning on multiple systems on the network.As its name suggests, waitfor can pause ascript until the command processor receives a specifiedsignal, and it can also send a signal to one or more systemson the network. The following command waits forthe ScriptDone signal:
waitfor ScriptDone
7. Wbadmin—Although you might not have aclue based on its name, the new wbadmin commandis Vista’s command-line backup tool. Thefollowing example shows how to use wbadminto backup the C and D drives to the share named backupon myserver:
wbadmin start backup -backupTarget:\myserver backup include:c:,d:
6. Icacls—The Icacls command replaces the oldercacls command. Icacls lets you list, update, andback up the access control lists (ACLs) for filesand directories. The following example showshow you can save the ACLs for the C:temp directory:
icacls c:temp /save tempacl
5. Winsat—Winsat is the new Windows SystemAssessment tool. It runs automatically whenyou install Vista, but you can run it on demandfor simple system benchmarking and systeminformation. For instance, to list your system information,you could run winsat with the features parameter:
winsat features
4. Clip—The new clip command is a handy toolthat copies the output of other command-linetools to the clipboard. The following exampleshows how to use clip to copy the contents ofthe file mytext.txt to the clipboard:
clip < mytext.txt.
3. Forfiles—The forfiles command is another usefulbatch-file tool. It executes a command overa set of files. Forfiles is much easier to use thanthe older and more obtuse for command. Thefollowing example shows how you could list all files morethan 30 days old in the c:temp directory:
forfiles /p c:temp /s /d -30 /c “cmd /c echo @file
2. WinRS—The WinRS tool is essentially the Windowsversion of Linux’s Secure Shell (SSH).WinRS lets you open a secure command windowto a remote host. All the contents of the remoteshell are encrypted. The following example connects tothe server named myserver and runs the dir command:
winrs -r:myserver dir
1. Robocopy—Without a doubt, the best commandlineaddition to Vista is robocopy. Although robocopyisn’t new to most of our readers (it’s been a staple in theWindows Resource Kit for years), Vista is the first releasethat includes robocopy as a part of the OS. Robocopy is asuper-powerful command-line copy tool. The followingexample shows how to create a mirrored copy of the directorycalled shares and all of its subfolders.
robocopy “C:Shares” “\server2 Shares Backup” /MIR /R:2 /NP
About the Author
You May Also Like