visual-studio 如何更改“devenv”命令位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1893223/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:18:41  来源:igfitidea点击:

How to change "devenv" command location?

visual-studiovisual-studio-2008windows-7

提问by Prashant

I have two versions of Visual Studio 2005/208 installed in my system (windows7), when I am opening Visual Studio with "devenv" command from "Run" window then its opening Visual Studio 2005 but I want when I open it using "devenv" command so Visual Studio 2008 should open by default.

我的系统 (windows7) 中安装了两个版本的 Visual Studio 2005/208,当我使用“运行”窗口中的“devenv”命令打开 Visual Studio 时,它打开 Visual Studio 2005 但我想在使用“devenv”打开它时" 命令,因此 Visual Studio 2008 应默认打开。

How can I do this in windows.

我怎样才能在 Windows 中做到这一点。

Thanks

谢谢

Note:I am not sure this question is for Stackoverflow or for Superuser so just asked it here, if this has any problem then (any moderator) please move it to superuser.

注意:我不确定这个问题是针对 Stackoverflow 还是针对超级用户,所以只是在这里提问,如果这有任何问题,那么(任何版主)请将其移至超级用户。

采纳答案by ChrisF

The problem is that both executables are called "devenv.exe".

问题是这两个可执行文件都被称为“devenv.exe”。

What will be happening is that while both the 2005 folder and 2008 folder are on your Windows search path, the 2005 folder occurs first. This means that the 2005 version is found first and gets executed.

将会发生的情况是,虽然 2005 文件夹和 2008 文件夹都在您的 Windows 搜索路径上,但 2005 文件夹首先出现。这意味着首先找到 2005 版本并执行。

Possible solutions:

可能的解决方案:

  • Rename the 2005 copy to be "devenv2005.exe" (for example). However, you will need to update any shortcuts that point to it to use the new name.

  • Edit your PATH environment variable to swap the order of the 2005 and 2008 directories.

  • 将 2005 副本重命名为“devenv2005.exe”(例如)。但是,您需要更新指向它的任何快捷方式才能使用新名称。

  • 编辑 PATH 环境变量以交换 2005 和 2008 目录的顺序。

The second is the least work - depending on how confident you are about editing environment variables.

第二个是最少的工作 - 取决于您对编辑环境变量的信心。

回答by Prasad Kanaparthi

You can follow these steps to open VS2008 from the command prompt using "devenv":

您可以按照以下步骤使用“devenv”从命令提示符打开 VS2008:

  1. Open the Registry Editor by typing regediton Run

  2. Locate and open the following key:

    My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe
    
  3. Currently for VS 2005, devenv.exeis mapped to

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe
    

    If you want open VS 2008 from the command prompt, you must change the map to

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
    

    Just change to 8to 9.0to switch from VS 2005 to VS 2008, or VS 2008 to VS 2005.

  1. 通过键入regedit运行打开注册表编辑器

  2. 找到并打开以下键:

    My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe
    
  3. 目前对于 VS 2005,devenv.exe映射到

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe
    

    如果要从命令提示符打开 VS 2008,则必须将映射更改为

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
    

    只需将8改为9.0即可从 VS 2005 切换到 VS 2008,或者从 VS 2008 切换到 VS 2005。

回答by Igor Zevaka

This is what i have:

这就是我所拥有的:

REM devenv8.bat
@echo off
"%VS80COMNTOOLS%..\IDE\devenv.exe"

REM devenv9.bat
@echo off
"%VS90COMNTOOLS%..\IDE\devenv.com"

It flashes command prompt momentarily, but I haven't worked out how to get rid of that. Will be interested to know how to have it not do that.

它会暂时闪烁命令提示符,但我还没有想出如何摆脱它。将有兴趣知道如何让它不那样做。

回答by kenny

My suggestion is to run Launchy, but I also +1ed the batch file approach. I should add, once with that approach I hotkey launchy, win-space for me, and type either '5' or '8' for vs05 or vs08.

我的建议是运行Launchy,但我也+1 批处理文件方法。我应该补充一下,一旦使用这种方法,我的热键启动,为我赢得空间,并为 vs05 或 vs08 键入“5”或“8”。

回答by D.Shawley

Make two batch files (devenv-2005.batand devenv-2008.bat) and use them instead of devenv. Make sure to set up the environment appropriately for each one and then launch devenv.exeusing the STARTcommand with a full path name from within the batch. There are utility batch files shipped with Visual Studio that will set up the environment (e.g., INCLUDE, LIB, PATH, etc.) for you. In VS2005, it was named vsvars32.bat. I would imagine that it is named similarly in VS2008.

制作两个批处理文件(devenv-2005.batdevenv-2008.bat)并使用它们代替 devenv。确保为每个环境设置适当的环境,然后devenv.exe使用START批处理中带有完整路径名的命令启动。Visual Studio 附带的实用程序批处理文件将为您设置环境(例如INCLUDELIBPATH、 等)。在 VS2005 中,它被命名为vsvars32.bat. 我想它在 VS2008 中的命名类似。

The other option is to find the environment script (vsvars32.bat) for VS2008 and modify your user environment to match. I would remove references to VS2005 from the environment altogether just to be safe.

另一种选择是找到 VS2008 的环境脚本 (vsvars32.bat) 并修改您的用户环境以匹配。为了安全起见,我会完全从环境中删除对 VS2005 的引用。