How to run a .bat file in Powershell from Visual Studio?

  • Post published:May 9, 2020

During software development, it becomes very useful to double click on a .bat file, in the Visual Studio solution explorer, so that it can be executed in Powershell.

Follow these steps to double click on a .bat file so that it can run in Powershell:

  • Right click on the .bat file in the solution explorer.
  • Select Open With... from the popup menu.
  • Click Add...
  • In the Program name text box, enter the full path of Powershell.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • In the Friendly name text box, enter Powershell.
  • Click OK.
  • Click on Set As Default.
  • Click OK.
Architect, design, code, test and share.

Going forward, to open .bat files in Powershell, simply double click on the .bat file.

Architect, design, code, test and share.

Summary

Visual Studio makes it very easy to execute .bat files in Powershell from the IDE by simply adding a new option to the Open With Visual Studio feature.

Software versions used in this article

  • Visual studio 2019 v4.8.03752