DOS Environment Variables in Login Scripts

  • 2905185
  • 21-Feb-1996
  • 22-Jan-1997
  • 4

Archived Content: This information is no longer maintained and is provided 'as is' for your convenience.

Issue

Q: Can DOS environment variables be used in login scripts?

A: Yes, DOS environment variables can be used in login scripts. In a conditional statement, the following syntax would be used:

IF <dos_environment_variable_name>="value" THEN
  commands
END

Or, you can use the % sign in front of the environment variable, but then it must be placed within quotes. Example:

IF "%<dos_environment_variable_name>"="value" THEN
  commands
END

NOTE: In either case, the brackets <> must be included around the name of the DOS environment variable.

For example, if there was a group of particular workstations that needed specific drive mappings and capture statements setup, regardless of the user logging in from that workstation, the following steps could be performed:

1. At the workstation, place the following command in the AUTOEXEC.BAT file:

   SET WSCONFIG=TRUE

2. In the login script, place the following statement:

   IF <WSCONFIG>="TRUE" THEN
     commmands
   END

Or,
 IF "%<WSCONFIG>"="TRUE" THEN
     commmands
   END

The MAP, COMSPEC, and FIRE PHASERS commands require a percent sign (%) in front of the DOS environment variable (i.e. MAP S16:=%<path>)