Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't want to modify the system path in Windows 7, or the user path either.

But when I start up a Command Prompt (cmd.exe), I would like the path within the command prompt to be modified to include a couple of additional directories on the path that I would like searched for when I type in commands.

I thought earlier versions of Windows had the ability via a .pif file, and there used to be an ability to put variables in the autoexec.bat (though that might have set the variables for all windows apps and this I want to avoid.

share|improve this question

migrated from Jan 6 '12 at 5:45

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

Interesting question. I just did some reverse engineering on VS Command Prompt, coz it does some thing similar. The short cut for this command prompt targets one batch file.

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

Following is some sample script which gets called eventually

  @echo Setting environment for using Microsoft Visual Studio 2010 x86 tools.
  @call :GetVSCommonToolsDir
  @if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR

  @call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit

  @if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
  @if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32
  @if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32
  @if "%Framework35Version%"=="" goto error_no_Framework35Version

  @set FrameworkDir=%FrameworkDir32%
  @set FrameworkVersion=%FrameworkVersion32%

  @if not "%WindowsSdkDir%" == "" (
      @set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%"
          @set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
      @set "LIB=%WindowsSdkDir%lib;%LIB%"

So you can have batch file similar to this, and every time to go to command prompt, you can use this.

Hope this helps you.

share|improve this answer
Yep, that will work, as long as I always launch the command prompt from my custom shortcut, which isn't a big deal. – MarkS Jan 6 '12 at 15:54

You must log in to answer this question.

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