| by Arround The Web | No comments

Safest Way to Run BAT File From PowerShell Script

PowerShell is the most powerful tool in Windows utilized to automate several administrative functions/tasks. On the other hand, Command Prompt is also utilized for performing administrative tasks. The script file created in Command Prompt has the “BAT” extension, while the script created in PowerShell has the “.ps1” extension. Moreover, BAT files can also be executed by using a PowerShell script.

This post will explain the process of running the BAT file from PowerShell.

How to Safely Run a BAT File From the PowerShell Script?

In order to run the BAT file in PowerShell, check out the provided instructions.

Step 1: Create a Batch File

First, let’s create a “BAT” file. To do so, open “Notepad” from the Start menu and write the given script in it:

@echo off

echo Welcome to LinuxHint



  • @echo off” command is used to hide the file path specified in the “Command Prompt” console.
  • echo” command is used to print the added text in the output.
  • pause” command prevents the batch file script from closing:

Now, save the script by clicking on the “File” menu and then trigger the “Save” button:

Write the desired file name and make sure to save the file “.bat” extension at the end:

Step 2: Run BAT File

Run the “BAT” from the “PowerShell ISE” program. For that reason, write the call operator “&” and then specify its file path within inverted commas:

Run the created script by clicking on the highlighted icon:


As you can see from the output that the “BAT” file has been executed successfully.


The safest way to execute the “BAT” file is by using the PowerShell script. For this purpose, first, open the “PowerShell ISE”, write the call operator “&”, and then write the file path within inverted commas. Finally, execute the script to run the BAT file. This post has demonstrated a procedure to run the BAT file from PowerShell.

Share Button

Source: linuxhint.com

Leave a Reply