I want to create a .bat file that will open Developer command prompt and there i need to change directory "cd .. " path " " and execute few commands there.
The Developer Command Prompt for Visual Studio is nothing more as the normal cmd with a bat script run at the start.
You can run this script by yourself.
call "%programfiles(x86)%\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
Working on this now.
my current .txt file has a hanged extension of (.bat) Which is batch.
Copy & Paste this within your batch file.
echo off
title My Test Batch File
:: See the title at the top.
echo Test file executed.
echo I am too lazy to write commands again and again.
C:\Program Files (x86)\Microsoft Visual Studio 14.0>
pause
Right Click on your project name under solution explorer, then locate open command line, select developer command Prompt or use shortcut: shift + Alt + ,
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.
The docs mention an executable called code, but I'm not sure where I can find that so I can put it on my path. The zip I downloaded from the VSCode site did not include any such executable. (I am able to run the .app just fine.)
Is this a Windows-only thing?
From the Visual Studio Code Setup page:
Tip: If you want to run VS Code from the terminal by simply typing 'code', VS Code has a command, Shell Command: Install 'code' command in PATH, to add 'code' to your $PATH variable list.
After installation, launch VS Code. Now open the Command Palette (F1 or ⇧+⌘+P on Mac) and type shell command to find the Shell Command: Install 'code' command in PATH command.
After executing the command, restart the terminal for the new $PATH value to take effect. You'll be able to simply type 'code .' in any folder to start editing files in that folder.
⚡️ The Easy Solution.
Download, install and open Visual Studio Code.
Open the Command Palette (⌘ + ⇧ + P on Mac) OR View ❯ Command Palette
🌟 3. Type shell command to find
Shell Command: Install 'code' command in PATH command
Install it and you're done
📟 Here's a complimentary GIF.
After that, you can use code or code . in the terminal.
code
Peace! ✌️
If you'd like to go a little bit further and learn a couple of great tips/tricks for using the VSCode CLI, I made a YouTube video on my workflows.
If you want to open a file or folder on Visual Studio Code from your terminal, iTerm, etc below are the commands which come as default when you install Visual Studio Code
To open Visual Studio Code from command line
code --
To open the entire folder/directory
code .
To open a specific file
code file_name
eg:- code index.html
We since updated the script to the following syntax to support multiple files and folders as arguments and to fix an issue with not detecting the current working directory properly:
code () {
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
}
Update for our VS Code 1.0 release:
Please use the command Install 'Code' command in path or Install 'code-insiders' command in path from the command palette (View | Command Palette) to make Code available to the command line.
For me on Macbook Book Pro 2019 MacOS version 10.15.6, shortcut to open command palette in VSCode was Shift + Command + P.
On opening it one has to just write install code and press enter.
After that just open the terminal and type code your vscode will start opening.
This was the tutorial I was looking for in this thread. It shows the way to open files in Visual Studio Code by writing code .
1.- Open the file
Bash
open ~/.bash_profile
Terminal OS
open ~/.zshrc
2.- Add in your file the :
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
3.- Reinicialize terminal and try in the folder you want to open
code .
4.- Then you can use it as shown in this comment: https://stackoverflow.com/a/41821250/10033560
I have a ~/bin/code shell script that matches the command #BengaminPasero wrote.
#!/bin/bash
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
I prefix ~/bin: to my $PATH which allows me to add a bunch of one off scripts without polluting my ~/.bash_profile script.
Note: Only for Windows Users.
As many folks already suggested ways to open code from command prompt using code . command. This will only open Visual Studio Code Stable build. But If you have downloaded Visual Studio Code Insider build/version (Which has all latest build/features but unstable version) then you need to follow below instructions in windows :
Go to Control Panel\System and Security\System. Click on Advanced System Settings
Click on Environment Variables
Under System Variables tab, Click on Edit for Path Variable
Add a new path C:\Users\tsabu\AppData\Local\Programs\Microsoft VS Code Insiders\bin
(or)
C:\Program Files\Microsoft VS Code Insiders\bin based on location at which you have installed vscode insider in your machine.
Open a new command prompt and type code-insiders . to open vscode-insider
build/version
After opening VSC and pressing (Command + Up + P) I tried typing in "shell command" and nothing came up. In order to get "Shell Command: Install 'code' command in PATH command" to come up, you must do the following:
Press (Command, Up, P)
Type > (this will show and run commands)
Then type Shell Command: Install 'code' command in PATH command. It should then come up.
Once you click it, it will update and you should be good to go!
MacOS X Launch from Command Line docs
On OSX Mavericks I created a bash script named vscode (adapted from the .bashrc in VSCode Setup) in ~/bin:
#!/bin/bash
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
vscode <file or directory> now works as expected.
If you are using VS Code Insiders:
code-insiders .
If you are using VS Code:
code .
If you install Your vs code in Download folder you need to move the VS code to Application folder then open the vs code ,then press shift + command + p after you will see the below image. Then you need to type code . Now you are good to go.
Try this one
Open Visual Studio Code and press Command + Shift + P then type Shell in command palette now you are able to find this option like Shell Command : Install code in PATH from suggested list in command palette. Select that options.
Open VSCode via Terminal/Command Prompt
That's it.
Now open your terminal type.
$ code .
Steps to run code . command in mac to start the VSCode app -
Open VSCode
Open command pallet(Cmd+Shift+P)
Enter Shell Command: Install 'code' command in PATH and select
You will get the notification saying Shell command 'code' successfully installed in PATH.
Restart the terminal and enter code .
This will open VSCode from the current folder files in it.
You can use the vscode: protocol that Visual Studio Code defines:
open vscode://file/full/path/to/project/or/file
You can also use
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code
if you do not fancy modifying your path
I discovered a neat workaround for mingw32 (i.e. for those of you using the version of bash which is installed by git-scm.com on windows):
code () { VSCODE_CWD="$PWD" cmd //c code $* ;}
its very simple:
Launching from the Command Line
You can also run VS Code from the terminal by typing 'code' after adding it to the path:
Launch VS Code.
Open the Command Palette (⇧⌘P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
source
https://code.visualstudio.com/docs/setup/mac
I ran: open -a "Visual Studio Code" [folder-name] to open a folder with my Visual Studio Code application. Folder name is optional if you just want to open the application. Not sure if this is exactly your use-case, but hope this helps!
This is what worked for me on Mac OS Catalina -- found here (thanks, Josiah!)
If you're on Mac OS Catalina, you need to edit your .zprofile instead of .bash_profile.
Edit your ~/.zprofile file: vim ~/.zprofile
Add the following code in it, on it's own line: code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Save the file: :wq
Re-run the updated file: source ~/.zprofile.
Test that running code . opens your current folder in VS Code!
In my case I had to use an alias:
alias code="/<PATH TO VSCODE>/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
You can add this alias in your ~/.bash_profile.
I added this to my ~/.profile
alias vscode='/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'
then
. ~/.profile
afterwards I can just do
vscode
from the terminal
Added this to /usr/local/bin/code, you might have to modify the path if they are different.
#!/usr/bin/env bash
CONTENTS="/Applications/Visual Studio Code.app/Contents"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$#"
exit $?
Make executable afterwards
sudo chmod +x /usr/local/bin/code
I had this issue because of VS Code Insiders.
The path variable was there but I needed to rename the code-insiders.cmd inside to code.cmd .
Maybe this is useful to someone.
For windows Users
just type in
>code .
More commands here
https://code.visualstudio.com/docs/editor/command-line
If you're using visual code insiders and you want to open a file or folder in Visual Studio Code insiders from your terminal or any other command line tool then you can refer to the commands below which come by default inside visual studio code insider.
To open Visual Studio Code from command line
code-insiders --
To open the entire folder/directory
code-insiders .
To open a specific file
code-insiders file_name
eg:- code index.html
VSCode now supports it out of the box with version 1.58. Just type:
$ cd path/to/your/directory
$ code .
The instruction given at VS Code Command Line for launching a path are incorrect; the leading colon shown in the example doesn't work. However, launching with a backslash terminated directory name opens the specified directory as expected.
So, for example,
code C:\Users\DAVE\Documents\Programming\Angular\StringCalculator\src\
opens the Visual Studio Code editor in directory C:\Users\DAVE\Documents\Programming\Angular\StringCalculator\src.
Important: The terminal backslash, though optional, is useful, as it makes clear that the intend is to open a directory, as opposed to a file. Bear in mind that file name extensions are, and always have been, optional.
Beware: The directory that gets appended to the PATH list is the \bin directory, and the shell command code launches a Windows NT Command script.
Hence, when incorporated into another shell script, code must be called or started if you expect the remainder of the script to run. Thankfully, I discovered this before my first test of a new shell script that I am creating to start an Angular 2 project in a local Web server, my default Web browser, and Visual Studio Code, all at once.
Following is my Angular startup script, adapted to eliminate a dependency on one of my system utilities that is published elsewhere, but not strictly required.
#echo off
goto SKIPREM
=========================================================================
Name: StartAngularApp.CMD
Synopsis: Start the Angular 2 application installed in a specified
directory.
Arguments: %1 = OPTIONAL: Name of directory in which to application
is installed
Remarks: If no argument is specified, the application must be in
the current working directory.
This is a completely generalized Windows NT command
script (shell script) that uses the NPM Angular CLI to
load an Angular 2 application into a Node development
Web server, the default Web browser, and the Visual
Studio Code text editor.
Dependencies: Unless otherwise specified in the command line, the
application is created in the current working directory.
All of the following shell scripts and programs must be
installed in a directory that is on the Windows PATH
directory list.
1) ShowTime.CMD
2) WWPause.exe
3) WWSleep.exe
4) npm (the Node Package Manager) and its startup
script, npm.cmd, must be accessible via the Windows
PATH environment string. By default, this goes into
directory C:\Program Files\nodejs.
5) The Angular 2 startup script, ng.cmd, and the Node
Modules library must be installed for global access.
By default, these go into directory %AppData%\npm.
Author: David A. Gray
Created: Monday, 23 April 2017
-----------------------------------------------------------------------
Revision History
-----------------------------------------------------------------------
Date By Synopsis
---------- --- --------------------------------------------------------
2017/04/23 DAG Script created, tested, and deployed.
=======================================================================
:SKIPREM
echo BOJ %~0, version %~t0
echo.
echo -------------------------------------------------------
echo Displaying the current node.js version:
echo -------------------------------------------------------
echo.
node -v
echo.
echo -------------------------------------------------------
echo Displaying the current Node Package Manager version:
echo -------------------------------------------------------
echo.
call npm -v
echo.
echo -------------------------------------------------------
echo Loading Angular starter application %1
echo into a local Web server, the default Web browser, and
echo the Visual Studio Code text editor.
echo -------------------------------------------------------
echo.
if "%1" neq "" (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %1
echo -------------------------------------------------------
echo.
cd "%~1"
call code %1\src\
) else (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %CD%
echo -------------------------------------------------------
echo.
call code %CD%\src\
)
call ng serve --open
echo.
echo -------------------------------------------------------
echo %~nx0 Done!
echo -------------------------------------------------------
echo.
Pause
$> open -a "Visual Studio Code" [file-name]
link your currentily folders to vscode.
Windows Registry Editor Version 5.00
; Directory\Background\shell => on empty space
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
#="VsCode"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
#="C:\\current-folder-vscode\\Code.exe ."
; Directory\shell => on a folder
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
#="VsCode"
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
#="C:\\current-folder-vscode\\Code.exe ."
If you install VS CODE using snap. You will need to add /snap/bin in your PATH environment variable.
so - open your .bashrc or .zshrc
and add /snap/bin in your PATH environment variable
reload terminal,
and than code comand will start it