Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interactive window to execute dos commands in visual studio

I know using External Tools options i can run a batch script or a cmd prompt. But here is what i need to do

I want to be able to call a dos prompt inside visual studio, which must be interactive. That way i won't be outside visual studio and can run all my dos commands in it. Is it possible? Or can i extend the command window and capture the commands which are typed and process them using my custom code?

Thanks

like image 589
Anirudh Goel Avatar asked May 25 '10 09:05

Anirudh Goel


2 Answers

There's the Tools.Shell command which may work for you. You use the /c switch to specify that the output for the executable is displayed in the Command window. Then you call cmd.exe with /C switch which instructs it to close after finishing the command. For example if you type:

Tools.Shell /c cmd.exe /C dir C:

This will print the output to the Command window. Unfortunately, unlike the output, the input doesn't work. So if you type:

Tools.Shell /c cmd.exe /C pause

The prompt will not wait for your input (pressing a key).

If that's OK for you, you can even define an alias for most of this. For example you define alias sh for Tools.Shell /c cmd.exe /C:

alias sh Tools.Shell /c cmd.exe /C

Then you simply use it as follows:

sh dir c:
like image 193
Peter Macej Avatar answered Oct 10 '22 13:10

Peter Macej


If you install NuGet, then it adds Package Manager Console to Visual Studio which is essentially a Powershell command prompt. There should be ways of doing most DOS stuff via Powershell and heaps more functionality as well.

like image 41
Bermo Avatar answered Oct 10 '22 13:10

Bermo