visual-studio 从命令提示符启动 Visual Studio
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/973561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Starting Visual Studio from a command prompt
提问by SNA
I have three different versions of Visual Studio installed on my machine, Visual Studio 2003, Visual Studio 2008, and VS2005.
我的机器上安装了三个不同版本的 Visual Studio,分别是 Visual Studio 2003、Visual Studio 2008和VS2005。
How do I start a particular version of Visual Studio using a command prompt.
如何使用命令提示符启动特定版本的 Visual Studio。
devenv.exeopens the latest version of Visual Studio. What should I do if I want to open Visual Studio 2003 using a command prompt?
devenv.exe打开最新版本的 Visual Studio。如果我想使用命令提示符打开 Visual Studio 2003,应该怎么做?
回答by RBarryYoung
You have to use the path to distinguish them. For instance, here is the Visual Studio 2005 command on my laptop:
您必须使用路径来区分它们。例如,这是我笔记本电脑上的 Visual Studio 2005 命令:
"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
Here's another tip: You can figure out how to run various Windows applications from the command line by finding them in the Windows Start Menu, right-clicking on the icon, select properties, and then on the Shortcut tab, look at the Target textbox. Copy that text out and usually you can use it at a console command line.
这是另一个提示:您可以通过在 Windows 开始菜单中找到各种 Windows 应用程序,右键单击图标,选择属性,然后在快捷方式选项卡上查看目标文本框,了解如何从命令行运行各种 Windows 应用程序。复制该文本,通常您可以在控制台命令行中使用它。
回答by ΩmegaMan
This answer is a different way to handle starting Visual Studio in Windows 7 through 10 by using the Windows Key {windows logo} startto startthe target application.
这个答案是用不同的方式来处理到10中使用Windows键启动Visual Studio的Windows 7中{windows logo} start,以启动目标程序。
- Pin each version to the task bar. One way is to right click an active running program and select 'Pin to Taskbar. Or find in the program manager and right click again to pin.
Pin each different version right next to the task bar. For this example pin each version in succession 2003, 2005 and finally 2008. Make sure they are next to the start button for easier index number memorization.

- To launch the 2003 version hit the
WindowsKeythen number1. - To launch 2005
WindowsKey 2. - To launch 2008
WindowsKey 3.
- 将每个版本固定到任务栏。一种方法是右键单击正在运行的活动程序并选择“固定到任务栏”。或者在程序管理器中找到并再次右键单击以固定。
将每个不同的版本固定在任务栏旁边。对于本示例,依次固定 2003、2005 和 2008 的每个版本。确保它们位于开始按钮旁边,以便于记忆索引号。

- 推出 2003 版打
WindowsKey当时的号码1。 - 2005年推出
WindowsKey 2。 - 2008年推出
WindowsKey 3。
This is fast and easy and can launch multiple instances without bringing up the command console.
这既快速又简单,并且可以在不打开命令控制台的情况下启动多个实例。
回答by JaredPar
Use devenv.exe for the specific version of Visual Studio. There will be one located in the Common7\IDE folder of the install. Here are the directories as I remember for the various versions.
将 devenv.exe 用于特定版本的 Visual Studio。将有一个位于安装的 Common7\IDE 文件夹中。这是我记得的各种版本的目录。
- 2008: %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\Ide\devenv.exe
- 2005: %ProgramFiles%\Microsoft visual Studio 8\Common7\Ide\devenv.exe
- 2008 年:%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\Ide\devenv.exe
- 2005 年:%ProgramFiles%\Microsoft Visual Studio 8\Common7\Ide\devenv.exe
回答by KoalaZub
Haven't tested on preceding versions - but to launch Visual Studio 2019 you can just enter start devenvto launch right away without entering into a path
尚未对之前的版本进行测试 - 但要启动 Visual Studio 2019,您只需输入start devenv即可立即启动,而无需输入路径
回答by RobS
You can also use the "Visual Studio 2005 Command Prompt" and "Visual Studio 2008 Command Prompt" to load a version-specific command shell environment, and then run 'devenv'. This is typically found under Start->Programs->Visual Studio ->Visual Studio Tools
您还可以使用“Visual Studio 2005 命令提示符”和“Visual Studio 2008 命令提示符”来加载特定于版本的命令外壳环境,然后运行“devenv”。这通常位于“开始”->“程序”->“Visual Studio”->“Visual Studio 工具”下
If you can't or don't want to access it via the Start menu, you can also "load" the VS-version specific environment in a normal command shell using the following (for VS 2008, with a default install path): (note: change x86 as appropriate for your platform)
如果您不能或不想通过“开始”菜单访问它,您还可以使用以下命令在普通命令外壳中“加载”VS 版本特定环境(对于 VS 2008,具有默认安装路径): (注意:根据您的平台更改 x86)
(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
(32 位)%comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
(64 位)%comspec% /k ""C:\Program Files (x86)\ Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
or for VS 2008 (with default install path):
或者对于 VS 2008(使用默认安装路径):
(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
(32 位)%comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
(64 位)%comspec% /k ""C:\Program Files (x86)\ Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
Each sets the environment so if you then subsequently execute 'devenv' it'll load the correxct version.
每个都设置环境,因此如果您随后执行“devenv”,它将加载正确的版本。
回答by pajics
1) devenv (to open VS)
2) devenv *.sln (then tab to autocomplete and enter to open VS and auto-load current solution)
1)devenv(打开VS)
2)devenv *.sln(然后tab自动完成并输入打开VS和自动加载当前解决方案)
By default, this only works in Developer Command Prompt. To make it work in a normal console (I use cmder) you need to add folder path to devenv.exe to the System environment variable name Path. For me that is this one:
默认情况下,这仅适用于开发人员命令提示符。要使其在普通控制台中工作(我使用cmder),您需要将 devenv.exe 的文件夹路径添加到系统环境变量名称路径。对我来说就是这个:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
You can also use this scriptand save it as vs.bat and then it will find for you *.sln file in the folder and automatically open visual studio with solution loaded (as in 2.)
您也可以使用此脚本并将其另存为 vs.bat,然后它会在文件夹中为您找到 *.sln 文件并自动打开 Visual Studio 并加载解决方案(如 2.)
回答by andes
For Visual Studio on a mac, you can:
对于 Mac 上的 Visual Studio,您可以:
open '/Applications/Visual Studio.app' [path_to].sln
open '/Applications/Visual Studio.app' [path_to].sln
I create an alias in my bash_profile so I can just navigate to a directory and open it in VS:
我在 bash_profile 中创建了一个别名,这样我就可以导航到一个目录并在 VS 中打开它:
echo "alias vs=\"open '/Applications/Visual Studio.app' *.sln\"" >> ~/.bash_profile
echo "alias vs=\"open '/Applications/Visual Studio.app' *.sln\"" >> ~/.bash_profile
回答by Mitch Wheat
Use an abolute path, for example, C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.
使用绝对路径,例如,C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe。
回答by Sanu Uthaiah Bollera
Here is the shortcut, You can just type devenv.exe and start visual studio

这是快捷方式,您只需键入 devenv.exe 并启动 Visual Studio

回答by Vignesh Subramanian
I tried the answer that has been accepted in this question but it didnt work for me
我尝试了这个问题中已接受的答案,但它对我不起作用
I was able to launch Visual studio from RUNby typing devenv.exein it.
我可以RUN通过输入来启动 Visual Studio devenv.exe。
WIN+R didnt work for opening RUN, so in command prompt, I typed the below path in command prompt
WIN+R 无法打开RUN,所以在命令提示符下,我在命令提示符下输入以下路径
c:\WINDOWS\system32\rundll32.exe shell32.dll`,#61

