How to run a batch file always as admin on Windows 11

Run batch always as admin
Run batch always as admin (Image credit: Future)

On Windows 11, batch files can be useful for automatically creating and running one or multiple commands in sequence to perform different tasks. The only caveat is that some actions usually require running the batch with administrative privileges.

Some applications and file types usually include an option on the properties page to run as administrator, but that's not the case for batch files. You can launch Command Prompt elevated to run the script or choose the option from the context menu, but these options can add some unnecessary extra steps and complexity for non-technical users. 

If you want to configure a batch file to run as an administrator with a simple double-click, you can use a shortcut to do the trick.

In this how-to guide, I'll walk you through the steps to run batch files always elevated on Windows 11.

How to run a batch always as admin on Windows 11

If you need to run a batch file as an administrator with just a double-click, you'll need to create a shortcut. This is because the properties page of this file format doesn't include such an option.

Create batch file on Windows 11

To create a PowerShell script with Notepad, use these steps:

  1. Open Start.
  2. Search for Notepad, and click the top result to open the app.
  3. Type the following lines in the text file to create a batch file: 

@ECHO OFF

ECHO Hello World! This batch file always runs as admin. 

PAUSE

(Image credit: Future)
  1. Click the File menu.
  2. Select the Save As option.
  3. Confirm a descriptive name for the batch using the ".bat" extension — for example, myBatch.bat.

(Image credit: Future)
  1. Click the Save button.

Once you complete the steps, you can proceed to configure the batch file to run as administrator with a double-click action. If you're getting started with batch files, you can check this guide to learn more about how to create and run these types of files.

Configure batch file to run as admin 

To run a batch file always as an administrator on Windows 11, use these steps:

  1. Open File Explorer.
  2. Click the New menu and select the Shortcut option.

(Image credit: Future)
  1. Click the Browse button. 
  2. Open the location and select the batch files.
  3. Click the OK button.

(Image credit: Future)
  1. Click the Next button.
  2. Confirm a name for the shortcut – for example, mybatch-admin.bat.
  3. Click the Finish button.

(Image credit: Future)
  1. Right-click the shortcut and select the Properties option.

(Image credit: Future)
  1. Click the Shortcut tab.
  2. Click the Advanced button.
  3. Check the Run as administrator option.

(Image credit: Future)
  1. Click the OK button.
  2. Click the Apply button.
  3. Click the OK button.

After you complete the steps, the next time you double-click the shortcut, the batch will run elevated on Command Prompt without needing extra steps.

The guide focuses on Windows 11, but you can also refer to these steps for previous versions of the operating system, including Windows 10, 8.1, and 7.

More resources

For more helpful articles, coverage, and answers to common questions about Windows 10 and Windows 11, visit the following resources:

Mauro Huculak

Mauro Huculak has been a Windows How-To Expert contributor for WindowsCentral.com for nearly a decade and has over 15 years of experience writing comprehensive guides. He also has an IT background and has achieved different professional certifications from Microsoft, Cisco, VMware, and CompTIA. He has been recognized as a Microsoft MVP for many years.