What Was I Thinking?

Follies & Foils of .NET Development
posts - 95 , comments - 352 , trackbacks - 0

Running Batch Files from the Solution Explorer in Visual Studio

If you want to run a batch (.bat) file from within Visual Studio, you need to add an external tool.

 

From the Tools menu select External Tools, and then click Add.

Fill out the values as illustrated below:

AddExternalTool AddExternalTool

 

Click OK to close the dialog.

 

Now you can select the bat file to run in solution explorer, and select the Run Batch File command from the Tools menu.  The output of the batch file will be echoed to the output window inside visual studio.

 

<Revised 6/2/10>

You can also run .bat files from the solution explorer directly by associating the default behavior of “.BAT” extensions to Powershell.

 

  1. Right click the batch file in the Solution Explorer
  2. Select “Open With…”  from the context menu
  3. Click “Add…”
  4. In the “Program name” textbox , specify the full path of PowerShell (“\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”)
  5. In the “Friendly name” textbox enter “PowerShell”
  6. Select “Set As Default”
  7. Click OK

Now when you double click your batch file in the solution explorer, it will shell out to powershell and execute.

Print | posted on Thursday, January 28, 2010 12:29 PM | Filed Under [ Visual Studio ]

Feedback

Gravatar

# re: Running Batch Files from the Solution Explorer in Visual Studio

Thank you for the tips. I had several problems trying to use .bat files with Visual Studio, to ease my work. I would like you to post here a list of helpful and common commands that can be used in batch files, besides changing path or creating log files.
3/31/2011 11:05 AM | blair rewards membership
Gravatar

# re: Running Batch Files from the Solution Explorer in Visual Studio

Thanks a lot!
6/21/2011 9:11 AM | surf
Gravatar

# re: Running Batch Files from the Solution Explorer in Visual Studio

Thanks! I was looking for such advice for a long time
6/23/2016 6:47 AM | Artem Russia
Gravatar

# re: Running Batch Files from the Solution Explorer in Visual Studio

Thanks, I've been running CMD externally and windows and setting current folder forever. Love having this in the output folder.
8/19/2016 11:08 AM | interscape
Gravatar

# re: Running Batch Files from the Solution Explorer in Visual Studio

Much simpler: https://visualstudiogallery.msdn.microsoft.com/4e84e2cf-2d6b-472a-b1e2-b84932511379
11/6/2016 6:41 AM | Erwin
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: