简体   繁体   English

如何更改“ devenv”命令的位置?

[英]How to change “devenv” command location?

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还是针对Superuser,所以在这里只问了一下,如果这有任何问题,那么(任何主持人)请将其移至超级用户。

You can follow these steps to open VS2008 from the command prompt using "devenv": 您可以按照以下步骤使用“ devenv”在命令提示符下打开VS2008:

  1. Open the Registry Editor by typing regedit on Run 通过在运行时键入regedit来打开注册表编辑器

  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.exe is mapped to 当前对于VS 2005, devenv.exe映射到

     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 如果要从命令提示符下打开VS 2008,则必须将映射更改为

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

    Just change to 8 to 9.0 to switch from VS 2005 to VS 2008, or VS 2008 to VS 2005. 只需更改为89.0,即可从VS 2005切换到VS 2008,或从VS 2008切换到VS 2005。

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. 将会发生的事情是,虽然Windows搜索路径中同时包含2005文件夹和2008文件夹,但2005文件夹首先出现。 This means that the 2005 version is found first and gets executed. 这意味着将首先找到2005版本并执行该版本。

Possible solutions: 可能的解决方案:

  • Rename the 2005 copy to be "devenv2005.exe" (for example). 将2005副本重命名为“ devenv2005.exe”(例如)。 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. 编辑PATH环境变量以交换2005和2008目录的顺序。

The second is the least work - depending on how confident you are about editing environment variables. 第二个是最少的工作-取决于您对编辑环境变量的信心。

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. 有兴趣知道如何让它不那样做。

Make two batch files ( devenv-2005.bat and devenv-2008.bat ) and use them instead of devenv. 制作两个批处理文件( devenv-2005.batdevenv-2008.bat ),并使用它们代替devenv。 Make sure to set up the environment appropriately for each one and then launch devenv.exe using the START command with a full path name from within the batch. 确保为每个环境分别设置适当的环境,然后使用START命令使用批处理中的完整路径名启动devenv.exe There are utility batch files shipped with Visual Studio that will set up the environment (eg, INCLUDE , LIB , PATH , etc.) for you. Visual Studio附带有实用程序批处理文件,这些文件将为您设置环境(例如INCLUDELIBPATH等)。 In VS2005, it was named vsvars32.bat . 在VS2005中,它被命名为vsvars32.bat I would imagine that it is named similarly in VS2008. 我可以想象它在VS2008中被类似地命名。

The other option is to find the environment script (vsvars32.bat) for VS2008 and modify your user environment to match. 另一个选择是找到VS2008的环境脚本(vsvars32.bat)并修改您的用户环境以使其匹配。 I would remove references to VS2005 from the environment altogether just to be safe. 为了安全起见,我将从环境中完全删除对VS2005的引用。

My suggestion is to run Launchy , but I also +1ed the batch file approach. 我的建议是运行Launchy ,但我也+1了批处理文件方法。 I should add, once with that approach I hotkey launchy, win-space for me, and type either '5' or '8' for vs05 or vs08. 我应该补充一下,一旦有了这种方法,我便会快速启动,为我赢得空间,然后为vs05或vs08输入'5'或'8'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM