[ Home ] [ Tech Tips ] [ Raspberry Pi ] [ Powershell ] [ Ubuntu ] [ Django ] [ About ]
PowerShell | Start PowerShell Script via Run.bat with arguments

PowerShell | Start PowerShell Script via Run.bat with arguments batch Script

An easy way to start up a PowerShell script is with a .bat file, Lets fire up the sHeLl! and get cracking! This is a quick one.    

Below is the basic script if you want to copy it into a file and save it as say "run.bat"

@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath="%ThisScriptsDirectory%Main.ps1"
SET arg1="Bonkers"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%"" ""%arg1%""'}";

 

Also can find it here on GitHub as well as a video below 


Luke Keam
Thank you for reading. Any questions, comments or suggestions email me [email protected]
Luke Keam
techgeek.biz

FOLLOW US

Name
Email:

AD