Run Batch File As Administrator

  



Most of the time, you run Windows batch files using the Command Execution Method, which replicates running them in a command prompt window (cmd.exe). But, what if you need to perform additional processing within the same job and you are running that batch processing in PowerShell? You have several methods to launch Windows batch files from within PowerShell using these methods:

You can start a command procedure from PowerShell with the following code. Replace the path and file with your own information.

Run Batch File As Administrator

Once you’ve called your batch file, you can customize it to the task at hand. For example…

If you want to capture the output of the .bat file, you can use:

Run Batch File As Administrator Cmd

If you want to start a process with your .bat file, you can use the PowerShell start-process cmdlet:

And, if you if you want to control cmd.exe, you can use this:

The batch file doesnt run as admin and based on my research it can't auto run as admin. My idea is to move the program install batch script to a separate folder and create a new batch script for the startup folder that will force the original batch file to run as administrator.

  • Most of the time, you run Windows batch files using the Command Execution Method, which replicates running them in a command prompt window (cmd.exe). But, what if you need to perform additional processing within the same job and you are running that batch processing in PowerShell? You have several methods to launch Windows batch files Read More.
  • To elevate batch files manually, you would right-click on it and choose Run as Administrator. Here is a way to automatically elevate a batch file that requires elevated privileges to run correctly. This is equivalent to choosing “Run as Administrator” by right-clicking a batch file. In either case, the UAC prompt would still show up.
  • To run the batch file as administrator on Windows 10 with the help of file explorer right-click on it. The properties show you the option to Run as Administrator. Click Yes on the confirmation dialogue box. It is one of the simplest methods to run batch file without command prompt.

The start-process cmdlet is a standard PowerShell cmdlet, so anyone can use it. JAMS users leverage it regularly and combine it with JAMS specific cmdlets in our PowerShell Scheduler to add intelligent automation to batch files.

Run Batch File As Administrator Windows 10

Not

Run Batch File As Administrator