Question

I'm using cl in cmd and having to run vcvars32.bat every time I open a cmd window is really a pain in the axx. Can anyone offer a way of running it automatically?

Était-ce utile?

La solution

From cmd /?:

If /D was NOT specified on the command line, then when CMD.EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if either or both are present, they are executed first.

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

    and/or

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

You therefore could add vcvars32.bat to one of those AutoRun registry values to have it executed for every cmd.exe instance (except when /D is explicitly specified, of course).

However, be forewarned that doing this could result in other weird side-effects (for example, it could cause other .bat/.cmd scripts to be run in an environment that they aren't expecting).

Autres conseils

A workaround that works for some people is to write a batch file and call it A.BAT and make a.bat launch vcvars32.bat. Put a.bat on the path and then it's a matter of opening the cmd prompt and typing a and enter and voila, you're set!

way old, but the easiest way to do this with, say, a shortcut created on your TaskBar is to modify your shortcut (in %appdata%\microsoft\internet explorer\quick launch\user pinned\taskbar, or thereabouts) so the target is:

%windir%\system32\cmd.exe /k vcvars32.cmd

that'll do exactly what you're looking for. The /k tells it to execute the string but keep the window open (string being your batch file). You can either put vcvars32 somewhere in your path, or specify the whole path to vcvars32.

You can use the script in http://www.alteridem.net/2010/09/02/visual-studio-2010-command-prompt-here to make it so when you right-click a folder in explorer the option shows up. After downloading and extracting the zip file you can modify the .inf to point to the correct path to your particular VS version (and change the displayed name if desired). Note the comment on the page about having to rename the file if you are running 64-bit Windows.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top