How to change "devenv" command location? - visual-studio

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.
How can I do this in 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.

You can follow these steps to open VS2008 from the command prompt using "devenv":
Open the Registry Editor by typing regedit on Run
Locate and open the following key:
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe
Currently for VS 2005, devenv.exe is 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 8 to 9.0 to switch from VS 2005 to VS 2008, or VS 2008 to VS 2005.

The problem is that both executables are called "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.
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.
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. 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. 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.
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.

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.

Related

Visual studio installer retains previous installation path [duplicate]

I had to reformat one of my drives (T:) and change its purpose. I had Visual studio 2015 installed on it, uninstalled it before formatting and now the drive has a different letter (can't change it, other things installed on it). I want to install visual studio 2015 again, but on the C: drive. When I run the installation, I get this:
The T: drive doesn't exist anymore, and I can't change the installation path to another drive.
I tried some solutions where I had to delete registry keys, but didn't succeed since most of the solutions were for older versions of visual studio. Is there a way to change the path?
Run installer in command line (Admin Mode) In folder keep File vs_community_ENU.exe
and put this command
vs_community_ENU.exe /uninstall /force
Then put this
vs_community_ENU /CustomInstallPath C:\VisualStudio2015
NewDrive:\VisualStudio2015
it work for me
Hope this helps
I had the same problem. I had an installed Visual Studio on a crashed harddisk.
I tried everything above, nothing worked. You should use this method as ultima ratio:
There is a VisualStudioUninstaller by Microsoft.
Download it
Extract it
Run it with Setup.ForcedUninstall.exe in an administrator command prompt
If this fails:
Start an elevated powershell:
install-package msi -provider PowerShellGet
get-msicomponentinfo '{777CBCAC-12AB-4A57-A753-4A7D23B484D3}' | get-msiproductinfo | uninstall-msiproduct -properties IGNOREDEPENDENCIES=ALL
Try again. If this fails, replace the GUID with one of the following:
Visual Studio 2015: {777CBCAC-12AB-4A57-A753-4A7D23B484D3}
Visual Studio 2013: {56E09E41-21B6-4F87-8D60-0787D028ECDD}
Visual Studio 2012: {DB786F13-64A8-45D7-8C03-0E819DF9F7B3}
Visual Studio 2010: {01696F98-947C-4CF9-8BD3-ABE70332FDED}
Sources: blogs.msdn.microsoft.com
and
landinghub.visualstudio.com
If this fails get an exorcist or/and reinstall your system.
I know you said it worked, but for some (including me) it did not. After multiple hours, however, I found a way. Here are the steps to my solution:
If you have not uninstalled VS2015 yet, do it through Control Panel.
Run the setup (ect. vs_community.exe).
If you cannot install on desired drive, keep reading here :)
Copy the path from where the VS2015 want you to install it on (e.g.: "D:\Programmer\Microsoft Visual Studio 14.0").
Open regedit(Just press windows key, type it in, and press Enter).
Warning, now you are in the windows registry, be careful or you may cause system-wide instability.
Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData Here there should be 2 folders called something like S-1-5-18 and S-1-5-21-345634235-23423416487. Just start with the one with the smallest number.
Go into the Components folder, and here you should see many folders with numbers and letters as name. Right click on the first of these, and click Search. ("Find" for Windows 10)
Paste the path from step 4. here, and make sure that the 3 top boxes are checked (they should be by default).
Right-click the first result of the search and click export. Save it somewhere you remember, then right-click it again and delete it this time.
Run the VS2015 setup again (vs_community.exe) and check if you can change the path now. If not go back to 9. and continue.
If it worked, just install VS2015 and just remember where you put your saved reg files. If anything goes wrong, you can restore them again by running the file.
Hope this helps someone!
This worked for me:
Start procmon and run the VS installation.
In procmon, find the relevant registry by looking for:
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\*\Components"
Make sure the key you've found was successfully opened (result should be SUCCESS)
Open regedit and find the relevant Components folder.
Search for the key you have found.
Export it for backup, and then delete it.
Hope it works for you too :-)
For me, it was the mistake of installing SQL Server Management Studio 2016 before installing Visual Studio 2015. SSMS 2016 is now based of VS 2015 Shell Core. And the new setup doesn't allow for any interaction except pressing the Install button. That way, part of VS 2015 was installed to C: drive. And hence, all options to change VS 2015 Enterprise install path failed.
I removed SMSS 2016 and, explicitly, VS 2015 Shell Core and then tried to install VS 2015 and it worked with Custom Path and Browse button.
You can use junction tool by Microsoft to create a REAL directory on other partition (e.g. D:\Program Files (x86)\Microsoft Visual Studio 14.0) and make a symbol link to it as C:\Program Files (x86)..., just like the command shows below, then windows will use C:\Program Fil.. as path and the real dirs/files are in D:\Prog...
junction.exe 'C:\Program Files (x86)\Microsoft Visual Studio 14.0' 'D:\Program Files (x86)\Microsoft Visual Studio 14.0'
Download junction tool from https://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
In case someone still has this problem (I had it, since I deleted my partition, on which Visual Studio was installed before):
Open the registry, go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup
and there you will find some files. At least one of these files should contain the old path. Delete the file and the installation should work now.
In case there are other people who couldn't get it to work with the solutions already posted, here's what I did:
My problem was, that I had VS installed on partition E. The harddrive containing E crashed one day, and I couldn't uninstall VS properly anymore.
/uninstall /force wouldn't do the trick, since the setup would crash every time.
So I took my partition "D" and gave it the letter "E". Now I was able to install VS to the specified path. After that, I uninstalled it with /uninstall /force and the setup finished successfully.
After that I changed the partition "E" back to "D" and was able to install VS to "D".
I hope this helps someone with the same problem.
I know this is old, but just so you know there are command line switches that are very helpful for this sort of thing. In the command prompt, call your executable followed by /CustomInstallPath then the directory, as follows (adjust your executable pathname, of course, as necessary):
vs_community__e45cb735eddf4e4b9d95904be6e1ba26.exe /CustomInstallPath
Just a heads up, this didn't work for me the first time, so don't be afraid to try a couple times. I left my computer for the weekend (logged out), and ran the exact same command without doing anything else and it worked. Go figure...
In powershell:
Remove-Item
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\CACBC777BA2175A47A35A4D7324B483D
see https://stackoverflow.com/a/33839884/3353857

VSInstallDir missing

I am using VS 2010 and Windows 7. I'm trying to run a homework problem for a class in 3D Graphics, but when I try to run the downloaded homework program, I get this error: "VSInstallDir is missing or empty". When I click on the solution's properties, I don't find a place to enter this variable. Homework is due 12/19, so there's a bit of a time crunch. What am I missing?
It may refer to an environment variable named 'VSInstallDir'
If your homework program uses command-line Visual Studio tools,
you can try to run it from the 'Visual Studio command prompt' (search for it using your Windows start menu).
Another option is to manually add it in Windows using System Properties (Windows Key + Break keyboard shortcut), goto Advanced, Environment variables, User variables and add it there.
It's value should be 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\' without the quotes if you have 64-bit windows or 'c:\Program Files\Microsoft Visual Studio 10.0\VC\' if you have 32-bit windows installed. You will have to restart Visual Studio for this.

How to use Visual Studio 2010 C++ tools in Visual Studio 2008?

If possible at all, does anyone know how to use the full c++ toolset shipped with Visual Studio 2010 (compiler/linker/sdk) in Visual Studio 2008?
Would changing all directories listen under Options->Projects and Solutions->VC++ Directories be sufficient, or is there more to it? And suppose I try it this way, are there any caveats to it?
I kinda forgot about this question until today a friend was saying how great C++0x was. I'm still in love with VS2008, much more than with 2010 which is above all things slow, so decided to give it a go.
And, I still can't believe it, but with a minimum of hacks it actually works.
And it works great: sitting before VS2008 you don't even notice it's actually using the 2010 toolset. Unless you look at cl/link's logo. Or off course, unless you are suddenly able to use lambdas. I could not find any problems so far whatsoever. Editing etc works like it alwasy did, building works, debugging works, that's all I need.
Here's what I did:
make a batch file setting up the envorinment for use with Windows SDK 7.1 / VS2010 toolset, but leaving devenv from the VS2008 installation. Mostly copied this from 2010's setenv.cmd.
now the dirty bit: copy msobj100.dll, mspdb100.dll , mspdbcore.dll and mspdbsrv.exe into the 2010's VSINSTALLDIR/bin directory (or put them in your PATH somweher). This is required else cl.exe doesn't work, nor would debugging.
launch from same command line where batch file was run using devenv /useenv
smile
This is the used batchfile for an x64 machine:
SET PlatformToolset=Windows7.1SDK
SET ToolsVersion=4.0
SET WindowsSDKVersionOverride=v7.1
SET Path32=%ProgramFiles(x86)%
SET "VCINSTALLDIR=%Path32%\Microsoft Visual Studio 10.0\VC\"
SET "VSINSTALLDIR=%Path32%\Microsoft Visual Studio 10.0\"
SET "VCTools=%VCINSTALLDIR%Bin"
SET "VCTools=%VCTools%;%VCTools%\VCPackages;"
SET "VCLibraries=%VCINSTALLDIR%Lib"
SET "VCIncludes=%VCINSTALLDIR%INCLUDE"
SET Path=%FxTools%;%VSTools%;%VCTools%;%SdkTools%;%Path%
SET OSLibraries=%WindowsSdkDir%Lib
SET OSIncludes=%WindowsSdkDir%INCLUDE;%WindowsSdkDir%INCLUDE\gl
SET "LIB=%VCLibraries%;%OSLibraries%;%FxTools%"
SET "LIBPATH=%FxTools%;%VCLibraries%"
SET "INCLUDE=%VCIncludes%;%OSIncludes%"
EDIT instead of batchfile combined with /useenv, there's another way that does the same but more direct: the settings for VC++ Directories are all saved in the file %APPDATA%/VisualStudio/9.0/VCComponents.dat. So if you take the original one and replace all occurrences of $(VCINSTALLDIR) with $(ProgramFiles)\Microsoft Visual Studio 10.0\VC\ it works as well.

Error while installing Microsoft visual studio Professional 2010

I am trying to install Microsoft visual studio Professional 2010 on my Windows XP SP3 edition. I am getting the error "vs_setup.msi could not be open" :
I have seen some forums mentioning the same problem for different reasons, and mostly because of having a previous version of Microsoft visual studio installed, but this is the first time for me to install it. Any idea how to fix that ?
Note: The actual setup files are in the path "G:\Visual Studio 2010 Professional". I do not know why the setup is trying to look for vs_setup.msi inside the "G:" directly ! Of course it is not there.
Maybe this setup is from DVD image and it's hardcoded to work in root directory.
Try to move all setup files to G:\ or another drive root
It probably doesn't like the spaces in the installation folder name. Rename "Visual Studio 2010 Professional" to VS2010Pro and see if it doesn't start working.
Also look for the setup log in %temp%. Sometimes it's cryptic but you can usually get SOME idea of what went wrong. Maybe edit your question with the errors from that log. It's called dd_something*something* etc.
Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package.
With 7zip open and extract VSIsoShell.exe in a New Directory (there are many files inside of this .exe).
After this is done, redirect to the right path w/ the extracted files (with vs_setup.msi file).
7zip is an Open source Windows utility for manipulating archives (www.7-zip.org)

Visual Studio Version Selector Doesn't open

I have Visual Studio 2008 and 2010 installed side by side, but trying to open either a 2008 or 2010 sln file results in nothing. The hour glass comes on for about a second and then it goes away and nothing is opened.
I read somewhere to relate sln file to VS directly, but I can't go that route because I don't want 2008 solutions to open with 2010. Does anyone know what the problem might be and how to fix it?
If you are running Vista or Windows 7 with the UAC enabled and have "Run this program as an Administrator" checked on the Compatibility tab for the Visual Studio exe (devenv.exe), you will get this behavior when you try to open a sln file directly from Windows Explorer.
One solution is to go to "%ProgramFiles%\Common Files\Microsoft Shared\MSEnv" or ("%ProgramFiles(x86)%\Common Files\Microsoft Shared\MSEnv" for 64-bit systems) and right-click VSLauncher.exe and select Properties. On the Compatibility tab, check "Run this program as an Administrator". Now when you try to open a sln file directly from Windows Explorer, you will get the elevation prompt and it will open the correct version of Visual Studio for the file.
Apparently, the "run as administrator" hack does not work anymore in Visual Studio 2010 SP1. Fabian describes a workaround here:
Getting Visual Studio 2010 SP1 to run elevated when launching .sln files
To sum it up:
Backup VSLauncher.exe
From within a Visual Studio 2010 Tools prompt, extract the manifest from VSLauncher.exe:
mt -inputresource:"VSLauncher.exe" -out:VSLauncher.exe.manifest
Alter the VSLauncher.exe.manifest file:
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false">
</requestedExecutionLevel>
</requestedPrivileges>
Write back the manifest into VSLauncher.exe:
mt -outputresource:VSLauncher.exe -manifest VSLauncher.exe.manifest
The really annoying thing about this problem is that you have to run Visual Studio as administrator under windows 7 to attach to an IIS instance. The least they could do was not break the .sln files when you do that!
The post by Jorge Poveda is correct though, the original hack no longer works but his does. It's maybe worth mentioning that you have to run everything as administrator for it to work (the command prompt and text editor).
I think there is a better way though as we have Win 7 at work which runs as administrator and didn't have this issue. The key difference is that with this fix, the admin prompt asks you to open VSLauncher.exe, but on my work machine, it asks to open devenv.exe so VSLauncher must be OK to open VS2010 somehow. I'll ask our infrastructure guys how they did it and post back.

Resources