1

In Windows 7, is it possible to set a path that automatically applies to every new Command Prompt (DOS) instance, but nowhere else? Note that the Advanced tab for My Computer properties as well as the DOS SETX command fail to address that last constraint.

1 Answer 1

0

The command prompt in Windows supports an AutoRun registry key that allows you to run a program each time a command prompt is opened.

Set sets variables, but only for that command session (whereas Setx is persistent), so that'll be what you want to use.

Example usage:

  1. Head to %USERPROFILE% (usually C:\users\<user name>).
  2. Create a new batch file with your commands in it.

e.g. (append a path to the existing PATH variable):

@echo off
set path=%path%;"C:\Extra Path To Include"
  1. Save the file (for example test.bat).
  2. Open RegEdit and head to "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor".
  3. Add a new Value named "AutoRun" with a Type of "REG_EXPAND_SZ" (Expandable String Value).
  4. Double-click the new value to edit the data.
  5. Add %USERPROFILE%\test.bat as the Value data.

RegEdit Screen Shot

OK everything and close RegEdit.

Open a command prompt (no reboot necessary) and your batch file should have run, setting the Path (which you can confirm with set path).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .