Computer Variables in Windows XP

Windows XP also defines a number of computer-related variables by default. For example, the %windir% or %systemroot% variables can be used to access the directory in which Windows XP is installed. Although this is usually C:\WINDOWS by default, it doesn’t have to be. On systems with multiple operating systems installed, this variable makes finding the current Windows installation folder a breeze, and eliminates guesswork.

Other computer-related variables that can come in very handy include %computername%, %systemdrive%, and %os%. The %computername% variable returns the name of the computer, %systemdrive% can be used to represent the active system drive (typically drive C), and the %os% variable will display the name of the operating system in use. When using %os%, this variable will always return the value Windows_NT on any system running NT, 2000, XP, or 2003, but this can be changed if you prefer. The main purpose of this variable is to distinguish NT-based systems from DOS-based systems like 95/98/ME.

Author: Dan DiNicolo

Dan DiNicolo is a freelance author, consultant, trainer, and the managing editor of 2000Trainers.com. He is the author of the CCNA Study Guide found on this site, as well as many books including the PC Magazine titles Windows XP Security Solutions and Windows Vista Security Solutions. Click here to contact Dan.