Tech Tips / Windows NT / Tools and Tasks

The basics of Windows NT command shell variables

Variables are indexes for memory counters that hold a specific value. NT command shell variables can contain either alphabetic or numeric values. To display the Windows NT command shell's preset environment variables, type the command SET. To declare a new variable and set its value, type:

   SET variable=value

Variable is the variable's name and value is the variable's value. The NT command shell treats all variables you set with the SET command as text unless you use SET with the /a parameter to type the variable as numeric. Once you've set the variable, you can substitute its value in a command by enclosing the variable's name in percent signs. For example, if you execute these three command statements:

   SET /a count=1
   SET /a count=%count% + 1
   Echo %count%

The last ECHO command statement will output the number 2 on the screen. The most important thing to remember about variable substitution is that the Windows NT command shell substitutes variables before it interprets any part of the command. Therefore, you can use variables to construct any part of a command statement, including a command itself.

Contact Us | Authors | Subject Index | Directory | RSS Feeds

Copyright ©2006 Setup32.com