Backing Up Files and Folders with the XCOPY Command

Back in the days before a graphical backup utility was included with Windows, the XCOPY command line tool handled this job. XCOPY is still a great tool for backing up files and folders to an alternate location, and supports a large number of switches to control everything from overwriting files to whether the archive attribute should be changed during the process.

The XCOPY command also supports wildcard characters such as * to allow you to select files with certain names or extensions in a single command. As an example, to back up all files in the c:\documents directory that have changed since October 28, 2005 to a directory called e:\backup, the correct syntax would be XCOPY c:\documents e:\backup /D:10-28-2005.

Manage Windows Processes from the Command Line with TASKLIST and TASKKILL

Only available on XP Professional systems, the TASKLIST and TASKKILL commands allow you to view (and kill, when necessary) the same running processes visible from the Processes tab in Task Manager. For more information on using these tools to view and kill tasks, see the steps below.

Step 1: Open the command prompt and type tasklist at the command line. Press Enter. A list of all running processes will appear, including useful information such as the process name and Process ID (PID). Note the PID of the task you wish to terminate.

Step 2: To kill a process, you need to identify it in conjunction with the TASKKILL command. For example, to terminate a task with a PID of 1572, enter the command taskkill /PID 1572 and press Enter.

Step 3: To confirm that the intended process has been killed, issue the tasklist command again and press Enter. The process associated with the PID specified in Step 2 should no longer be running. Issue the taskkill /? command for more information on how processes can be terminated.

Gathering System Information with the SYSTEMINFO Command

The most common tool used to gather general details about the configuration of an XP system is via the graphical System Information tool. If you’re running XP Professional, however, this information can also be gathered from the command line using the SYSTEMINFO command line utility. When issued without any switches, this tool will display system configuration information including your BIOS version, time zone, IP address, installed hotfixes, and more, as shown below. When you only need a quick heads-up, this command is much quicker to access that the GUI version and makes obtaining information a snap. Unfortunately, this command is not available on XP Home systems.

Using the PRINT Command to Send Files for Printing from the Command Line

Most users are familiar with the standard GUI-based methods of sending a file to a printer, including the File > Print menu in most applications, or the CTRL+P keyboard shortcut. However, it’s also possible to send a text document to a configured serial or parallel port printer from the command line via the PRINT utility. To do so, simply issue the command PRINT /D:device followed by the name of the file to print.

An example of sending a file named test.txt to a printer connected to port LPT1 would be accomplished via the command PRINT /D:LPT1 c:\test.txt.

Windows File Management with the FIND and FINDSTR Commands

File management can be tricky business, especially if you want to find files that contain certain words or phrases. The FIND and FINDSTR utilities help here, allowing you to search for text strings in files or determine which files contain those words. For example, if you wanted to display all of the lines in the file c:\test.txt that included the string “Dan” along with the line number that this string appears on, type FIND /N “Dan” c:\test.txt.

The FIND and FINDSTR commands include a number of different switches, and provides a variety of search options, including the use of wildcard characters.

Replacing Windows XP Files with the EXPAND Command

Given the explosive growth or viruses and other malicious email attachments, it’s no surprise that critical XP system files will occasionally become damaged corrupted. Certainly these issues aren’t the only cause of file issues, but if your system fails to boot or is displaying error messages relating to a certain file, it may be time to replace it with the original version from your Windows XP CD. When stored on the CD, these files are compressed, with a filename ending in an underscore “_” character. To replace an installed version of the file with one from CD, use the EXPAND utility. For example, to replace a file from CD such as the Windows Task Manager utility, the command would be EXPAND d:\i386\taskmgr.ex_ c:\Windows\system32

Note: When using the EXPAND command to replace files, be sure that the source files on the CD are of the same version as those currently installed. In other words, to replace a file on a Windows XP system with SP2 installed, be sure to use a Windows XP with SP2 source CD.

Changing File Attributes with the ATTRIB Command

Although the XP GUI allows you to change attributes from the properties of a file or folder, the command line ATTRIB tool is a much faster and more flexible alternative. One benefit of this tool is that it allows you to configure the System attributes for a file, which isn’t possible via the graphical interface. This is useful because when a file or folder has both its Hidden and System attributes set, the file is completely hidden in the Windows Explorer interface by default.

To view the attributes associated with a file or folder from the command line, type ATTRIB followed by the file name. To add attributes to a file, use the ATTRIB command followed by +R +H +A or +S (and then the path/filename) to add the Read-only, Hidden, Archive, and System attributes to the file respectively. The –R –H –A and –S switches remove these attributes from the file.

Copying Floppy Disks with the DISKCOPY Command

They might seem a little old school, but floppy disks are still around and useful when you’re in a pinch. The DISKCOPY utility is a simple command-line tool that allows you to copy disks of the same type (such as two 3 ¼ inch floppies) between different drives or the same drive. For example, if you wanted to make an identical copy of a particular floppy disk using your A: drive, the command would be DISKCOPY a: a: /V. The /V switch verifies that the disk was copied correctly after the information completes.

Defragmenting Drives from the Command Line with DEFRAG

Defragmenting partitions is an important part of regular system maintenance to ensure that disks perform optimally. Although XP includes the GUI-based Disk Defragmenter tool, the DEFRAG command line version of the tool is a simple and effective alternative. To run the tool and force defragmentation on drive E:, the command would be DEFRAG e: -f.

To simply analyze the level of fragmentation on the same disk, the command would be DEFRAG d: -a.

Converting Drives to the NTFS File System with the CONVERT Utility

Windows XP supports three different file systems – FAT, FAT32, and NTFS. Although the FAT32 file system is a reasonable and well-performing file system for large partitions, it does lack one key feature, namely security. In order to be able to secure files and folders with security permissions (as well as use features like file system encryption and compression), you need to be using NTFS. Many vendors ship XP systems with all partitions formatted using the FAT32 file system, but this doesn’t have to be an issue. Windows XP includes the command line CONVERT utility to allow you to convert existing FAT or FAT32 partitions to NTFS without losing any of the data stored on those drives. In other words, this command avoids the need to format any partitions to change the file system.

To change a partition like D: from FAT to NTFS, type CONVERT d: /fs:ntfs at the prompt and let XP change it. If the drive is currently in use, it will be convert when you next reboot. Note that the CONVERT command can be used to convert FAT or FAT32 partitions to NTFS, but not vice versa.