6

Possible Duplicates:
Set Permanent Environmental Variable in Windows XP
Is there a way to set Windows environment variables from the command line PERMANENTLY

The set command does not save values between cmd.exe sessions. How can I save environmental values between new cmd.exe sessions?

For example the set command will work for my current session only:

set path=%path%;C:\Mingw\bin

Upon restarting cmd.exe my path string has been reset.

Possible solution: .bashrc or .bash_profile equivalent for DOS

snmcdonald
  • 247
  • 1
  • 4
  • 10

4 Answers4

11

Use SETX as per answers in this thread (linked from the right hand side here as a related question): Is there a way to set Windows environment variables from the command line PERMANENTLY

AdamV
  • 6,177
  • 2
  • 22
  • 38
3

Add/change them from Global environment variables. To access this (Assuming Windows XP as your OS ), right click on My Computer -> Properties -> Advanced Tab -> Environment Variables and add whatever is required.

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
1

You have several options:

Assuming Windows XP Pro:

  1. Go into c:\windows\system32\autoexec.nt and change to add the path there.
  2. Right click My Computer, go into properties, Advanced, Environmental Variables, change there.
  3. Create a login script. Right click My Computer, go into Manage. Go into Local Users and Groups, then Users. Right click the login, choose properties, go into Profile and set th Logon script. The default location it looks for login scripts are c:\windows\system32\repl\import\scripts.
Blackbeagle
  • 6,634
  • 20
  • 25
  • What is a login script going to do? Using set only applies to that specific cmd instance. It will run and then not affect any following command prompt sessions. – MDMarra May 28 '10 at 21:34
  • You can set the environment in the login. It then that gets forced into the environment variable space. Subsequent command prompt sessions inherit those variables. SetX or Setenv can be used here. – Blackbeagle May 28 '10 at 22:18
  • You don't need to use setx or setenv more than once, so doing it every login is unnecessary. – MDMarra May 28 '10 at 22:46
  • True, it should modify the registry. I isn't necessary to keep pushing it, but at least there is a stake marker somewhere that you did push something. If you did it from the command line or from the GUI, you don't know that it happened later. Keeping it here is redundant on boot, but a permanent place to look later to see what you did. – Blackbeagle May 29 '10 at 00:18
  • echo %path% should be enough to show you what you've added to your path. – MDMarra May 29 '10 at 05:00
0

To get Windows to save environment variables, Right-click on My Computer, click Properties, then Advanced | Environment Variables and edit it there.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247