Close this search box.

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:

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.

posted on Thursday, January 28, 2010 12:29 PM

This article is part of the GWB Archives. Original Author: What Was I Thinking?

Related Posts