Change directory in visual studio command prompt - visual-studio

I want to know what is the command I should execute in the command window of the visual studio 2013, to change directory to:
C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish/<Most_Recent_Version>/OutlookAddin_TemporaryKey.pfx
What is the command I must execute?

Actually, cd cmd works, but in a bit diff like this:
syntax:
cd /d c: or e: etc..
where /d stands for drive
for instance:
cd /d C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish//OutlookAddin_TemporaryKey.pfx
No need for the single or double quote in this case.
Now to execute any type of files for instance simply add '.\' before the executed one.
syntax:
.\OutlookAddin_TemporaryKey.pfx or .\example.exe what so ever

cd does work. However, keep in mind that if the path you're trying to get to has spaces, you need quotes around it (the path). E.g.:
cd "C:\Program Files\Microsoft Visual Studio 10.0" Also, note that the
"Visual Studio command prompt" that is mentioned in Step 6 is not the
"Visual Studio Command Window" - I think this is where the problem
comes from. The command prompt is a separate executable that you can
start by clicking Start, point to All Programs, point to Microsoft
Visual Studio, point to Visual Studio Tools, and then click Visual
Studio Command Prompt. Alternatively, just search "Visual Studio" in
the search bar in the Start menu, and it should show up
Source: Using the Command Window in Visual Studio

First create a file on CMD (COMMAND PROMPT)
1.cd desktop
2.mkdir filename
3.cd filename
4. code .
(It has to be a space between code and the dot to open up the file in visual studio code)
Note: If you just want to open visual studio, then go to CMD and just type in 'code' without the dot.

Related

How to open a file using Visual Studio debugger commands

Is it possible to open a file using debugger commands options of Visual Studio?
For example I want to run my program (with some command arguments) and then open a file.
The cmd equivalent would be:
app.exe args & file.png
Can I do the same thing in visual studio using projects settings or any other way?
You can use dev command prompt inside Visual Studio to achieve the same result
You can open Developer Command Prompt from Tools > Command Line menu
Then just type in whatever command you use in cmd

VS 2015 Command Prompt Error:"the filename,directory name, or volume label syntax is incorrect"

Added a command prompt to VS 2015 with these instructions:
Open Tools -> “External Tools…”
Click “Add”
Enter the following information into the new tool screen:
Field Value
Title VS Command Prompt
Command: C:\Windows\System32\cmd.exe
Arguments: /k “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat”
Initial Directory: $(SolutionDir)
Save your changes (and re-order your tools to suit your preferences). The “VS Command Prompt” will now be available in:
Tools -> VS Command Prompt
Every time the prompt is opened, it shows the error "the filename,directory name, or volume label syntax is incorrect".
Is there anything else I can do in VS or add a path to the environment variables?
The problem is in the argument
/k “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat”
It should be
/k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
I encountered the same problem when I copied the argument from the website
https://www.stevefenton.co.uk/2015/06/add-visual-studio-command-prompt-to-visual-studio-2015/

Running visual studio code in the current folder with batch file

I can follow below sequence of actions to run the Visual Studio Code in the current folder.
select the location bar in the current folder and run
(ALT + D):
cmd /k code .
I've tried to wrap the code . in the batch file (and place it in a folder where is declared in the PATH variable to run it as its own), it launches "Visual Studio Code" but doesn't close the command window until i close the visual studio code.
i know "start" command need to be there with exit command in the end but so far the combinations i've tried didn't really let me achieve that.
cmd.exe /k code .
exit
Any ideas?
this works for me,
Do not omit the first empty quote
Start "" "C:\Program Files (x86)\Microsoft VS Code\code.exe" <path_to_dir>\.
This works for me (be sure to start code and exit at the bottom of the batch file):
start "" code
exit
If you just want to start vscode from current folder from command line
type
code %cd%
Starts Visual Studio Code in current folder
#start code .
Starts Visual Studio Code in specific folder
#start code "<Specific Folder>"
Starts Visual Studio Code with a specific file
#start code "<Specific File>"
Save file as .bat
It works fine when I create cmd file with that script on the Windows 10 OS:
code c:\\path\\to\\Project | exit
[Run as] VS code extention for "Right click a file to run as the parameter of command in terminal."
https://marketplace.visualstudio.com/items?itemName=plylrnsdy.run-as
I tried this in command prompt and powershell:
call code
It works for me.

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.
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.
Add it as an external tool to Visual Studio (2008 shown here, should be similar in other versions):
Select "Tools", "External Tools...".
Click Add
Title: &Cmd
Command: cmd.exe
Arguments: /k "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
Initial Directory: $(SolutionDir)
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.
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.
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
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
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.
Copy Windows Command Processor from "C:\Windows\System32\cmd.exe" and paste to "C:\Your\Project\Directory\cmd.exe"
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
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\""

Visual Studio 2010: Opening a file using command line resets window layout

The following command works fine. It opens a new instance of Visual Studio 2010:
devenv
But if I specify a file name, Visual Studio's window layout will be reset.
devenv "D:\Temp\test.txt"
Any ideas? Thanks.
Update:
This command works:
devenv /command "open D:\Temp\test.txt"
But the file path cannot contain spaces. The following command gives an error: "The operation cannot be completed. The system cannot find the file specified":
devenv /command "open D:\Temp\test 2.txt"
I tried:
devenv /command "open 'D:\Temp\test 2.txt'"
But got the same error.
OK I think understand now.
Visual Studio uses different layouts for different situations. It uses a special layout when it is opened from command line with a specified file name.
I have never custom this layout so it looks like the default one, made me thought the layout was reset.

Resources