How to Shell Out to Batch in PowerShell

Microsoft PowerShell is a task-automatic framework typically used for the purpose of executing commands, such as "cmdlets," "PowerShell functions," and executable software applications. A batch file is a text file in which lines of executable commands are stored. Upon execution of the batch file, each command is executed in chronological order. You can use a specific command in Command Prompt to call a batch file via Microsoft PowerShell. This method would be useful if you wanted to execute PowerShell ".ps1" files from the batch file.

Instructions

    • 1

      Move the batch file -- which, for the purpose of this article will be named "example.bat" -- to the root directory on your main system hard disk drive (c:\). The batch file should be located at the following location: "c:\example.bat."

    • 2

      Click on the Windows "Start" button, then type "Command Prompt" in the search text field. Click on "Command Prompt," which will be the first item in the search results list. This will open a Command Prompt in a new window.

    • 3

      Type the following command: "powershell -noexit c:\example.bat" and press "Enter" on your keyboard. Rename "example.bat" to the actual name of the batch file.

Related Searches:

References

Comments

Related Ads

Featured