(Contents)(Previous)(Next)

Changing Environment Variables Globally

When a DOS window is opened during the execution of Windows 95, it will get a copy of the environment variables initially specified in the AUTOEXEC.BAT file or set by Windows upon startup. This copy is called a local environment. A list of the currently active local environment variables can be displayed in the DOS box by the SET command without any parameters. Any environment variables added inside the DOS box are only valid and active during the execution of that particular DOS box. Once this box is closed the local environment is destroyed and its environment variables are discarded and not added to the global environment.

Environment variables specified in the AUTOEXEC.BAT file are included in the global environment, but changes to the AUTOEXEC.BAT file take only effect when Windows is restarted.

Sometimes it might be desired to add a variable to the global environment after Windows has been started. The WINSET command adds variables to the global environment after Windows has been started with the following syntax:

WINSET environment_variable_name=enviroment_variable_string

The syntax of the WINSET command is identical to that of the SET command. However the WINSET command without any parameters will not give a list of either the global or local environment.

The local environment of any DOS box active when WINSET is run still remains unaffected. But any DOS box opened after the WINSET command has been run will get a copy of the new environment variable.

WINSET can also be used to eliminate an AUTOEXEC.BAT file that only exists to set some environment variables. You must include WINSET commands in a batch file that is placed in the StartUp folder to set the environment variables automatically every time you start Windows.

WINSET is not automatically installed during the Windows installation. It is located on the CD-ROM in the directory ADMIN\APPTOOLS\ENVVARS. It can also be downloaded from the Microsoft web site. The recommend location for WINSET is the \WINDOWS\COMMAND directory. Since this directory is usually included in the executable path or the environment variable COMSPEC points to this directory, WINSET can be called from any DOS box or with Start\Run.


(Next)