Change Default Visual Studio Command Prompt Locati

2019-06-15 19:26发布

How to set the default visual studio command prompt location so that I can go straight to my project's directory instead of using the usual navigation.

7条回答
Bombasti
2楼-- · 2019-06-15 19:47

In Visual Studio 2013,

Right click on "Developer Command Prompt for VS2013" shortcut (which you can find in the "Common7\Tools\Shortcuts" folder from where you installed your VS2013) and choose "Properties",

Change the: "Start in: " directory to your desired location.

查看更多
贪生不怕死
3楼-- · 2019-06-15 19:52

this will add a menu entry "my compiler " to each directory giving you access to the command prompt in the directory. save it as something.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\My Compiler]

[HKEY_CLASSES_ROOT\Directory\shell\My Compiler\command]
@="cmd.exe /k   \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\vcvarsall.bat\""
查看更多
别忘想泡老子
4楼-- · 2019-06-15 19:55
  1. Copy Windows Command Processor from "C:\Windows\System32\cmd.exe" and paste to "C:\Your\Project\Directory\cmd.exe"
  2. Edit Visual Studio Command Prompt shortcut by replacing %comspec% with "C:\Your\Project\Directory\cmd.exe" in the Target field.

So the shortcut's Target should look something like: "C:\Your\Project\Directory\cmd.exe" /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64

查看更多
爷、活的狠高调
5楼-- · 2019-06-15 20:05

Add it as an external tool to Visual Studio (2008 shown here, should be similar in other versions):

  1. Select "Tools", "External Tools...".
  2. Click Add
  3. Title: &Cmd
  4. Command: cmd.exe
  5. Arguments: /k "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
  6. Initial Directory: $(SolutionDir)

enter image description here

Note the arguments come from the "Visual Studio 2008 Command Prompt" shortcut. Yours may vary.

You can can customize the toolbar and add a button for this command as well using "Tools", "Customize...". Open the Tools menu and locate the last External Tool you created and drag it onto the toolbar.

When you click the button, it will open a command prompt in the current solution's root directory.

查看更多
Lonely孤独者°
6楼-- · 2019-06-15 20:05

For Visual Studio 2017 Command Prompt, you need to set environment variable VSCMD_START_DIR to the directory where you want to end up after the command prompt initializes.

I use this script:

set VSCMD_START_DIR=%1 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"

It accepts the directory as the first (and only) argument.

查看更多
趁早两清
7楼-- · 2019-06-15 20:07

You can put these lines in a batch script (vcvar.bat) located in the directory you want to start with:

@echo off

set VCDIR=%ProgramFiles%\Microsoft Visual Studio 10.0\VC
if not exist "%VCDIR%" set VCDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC
call "%VCDIR%\bin\vcvars32.bat"

Fire a command prompt in this directory, and call vcvar.bat. You now have the VS environment in the command prompt.

查看更多
登录 后发表回答