Environment Variables Not Set by "Double-Click" Or Available in Another Command Window

Article translations Article translations
Article ID: 263105 - View products that this article applies to.
This article was previously published under Q263105
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

SYMPTOMS

When an environment varibale is defined from a batch file or from the command-line, the defined variable and value do not appear in other command-line windows (Ntvdm.exe instances) and/or are not available to programs.

CAUSE

The set command defines a variable only for the current command line session, (Ntvdm.exe).

When you double-click a batch file, the batch file runs in its own NTVDM session and then closes, so the environment variable does not show up when you open a new session or look in another session to see the values.

RESOLUTION

The solution is to use setx from the Windows NT resource kit, because it can establish environment variables for a user session or define a system variable.

Setx has three modes of operation: it can define a variable for the user's session, or the system overall, or it can extract a value from the registry and set the result to the user session or the system. See the examples below:

To set a system variable:
setx color blue -m

To set a user variable:
setx color green

To extract a registry value and set a variable to a system variable:
setx color -k HKEY_CURRENT_USER\Console\ScreenColors -m
(To set a registry key value to a user session variable simply omit the -m switch)

STATUS

This behavior is by design.

Properties

Article ID: 263105 - Last Review: February 28, 2014 - Revision: 2.2
APPLIES TO
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows NT Server 3.5
  • Microsoft Windows NT Server 3.51
  • Microsoft Windows NT Server 4.0 Standard Edition
  • Microsoft Windows NT Workstation 3.5
  • Microsoft Windows NT Workstation 3.51
  • Microsoft Windows NT Workstation 4.0 Developer Edition
Keywords: 
kbnosurvey kbarchive kbenv kbnofix kbprb KB263105

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com