Lch
Lch

Reputation: 176

Change Default Visual Studio Command Prompt Location

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.

Upvotes: 15

Views: 20047

Answers (8)

mialkin
mialkin

Reputation: 2781

For Developer Command Prompt for VS 2019 you can set VSCMD_START_DIR environment variable with the following command:

setx VSCMD_START_DIR C:\your-folder

Upvotes: 5

John
John

Reputation: 79

Navigate to the "vcvarsall.bat" file. For me the path is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat

Add this line to the bottom of the script:

cd /d "D:\WhereverYouWant"

skol

Upvotes: 3

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.

Upvotes: 10

Neo Mosaid
Neo Mosaid

Reputation: 419

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\""

Upvotes: 1

hatef
hatef

Reputation: 6199

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.

Upvotes: 7

Blah Yada
Blah Yada

Reputation: 11

  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

Upvotes: 1

Mark Tolonen
Mark Tolonen

Reputation: 177406

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.

Upvotes: 8

CharlesB
CharlesB

Reputation: 90276

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.

Upvotes: 2

Related Questions