Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to open Visual Studio Command prompt using (Windows + "R")? Normally we use "cmd.exe" to launch command prompt. Is there any command to launch visual studio command prompt in a similar way?
Posted
Comments
Karthik_Mahalingam 6-Jan-14 4:39am    
try devenv.exe
Dinesh Thammineni 6-Jan-14 6:27am    
thanks, but devenv.exe is used to open visual studio using command prompt. I need to open visual studio command prompt using Window + R

Go to Tools -> External Tools ... in VS and check the parameters for Visual Studio command Prompt, it will be something like:
/K "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"

You can then add those to the cmd.exe setting and it should work.
 
Share this answer
 
Comments
Dinesh Thammineni 6-Jan-14 6:30am    
Thanks, This is working fine, but can you please provide solution for below problem ... that i have added in solution 4??
Go to Start->All Programs-> Microsoft Visual Studio 2010->Visual Studio Tools
There you will find Visual Studio Command prompt, right click on that and open the properties
In properties, open Shorcut tab, within that you can find Shortcut key field, put the focus in that field and press, Ctrl + K, it will create a shortcut Key for you...

Target for Visual studio command prompt: %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
 
Share this answer
 
Comments
Dinesh Thammineni 6-Jan-14 6:30am    
Thanks, This is working fine, but can you please provide solution for below problem ... that i have added in solution 4??
Hi Try this

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 2008\VC\vcvarsall.bat"" x86
 
Share this answer
 
Comments
Dinesh Thammineni 6-Jan-14 6:25am    
Thanks, This is working fine, but can you please provide solution for below problem ... that i have added in solution 4??
Hi All, %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 2008\VC\vcvarsall.bat"" x86
this is working fine, but is there a way to invoke the same using C# code.
I am using the following code

C#
Process genrate = new Process();
string openVisCmd; openVisCmd = "%comspec% /k " + @"""""D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat""""" + " x86"; genrate.StartInfo.FileName = openVisCmd;
//genrate.StartInfo.FileName = "cmd"; 
genrate.StartInfo.UseShellExecute = false;
genrate.StartInfo.RedirectStandardOutput = true;
genrate.StartInfo.RedirectStandardInput = true;
genrate.Start(); 



it is throwing "The system cannot find the file specified" exception. But when I use the same in windows + R, i am able to open visual studio command prompt.
 
Share this answer
 
Comments
Richard MacCutchan 6-Jan-14 6:42am    
You cannot use %comspec% here as it has no meaning ouside of a command shell. You must use the valid path of an executable program, such as "cmd.exe". You also do not need all those extra double quote around your parameter string.
Hi Dinesh,

You should change your code and try this oneline code

System.Diagnostics.Process.Start(Environment.GetEnvironmentVariable("COMSPEC"),  " /K " + @"""""D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat""""" + " x86");


Sure this will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900