Win10/Win11 Always run all batch files as administrator

This time, we will show you how to always run all batch files as administrator in Windows 10/11.

If you want to use a batch file to access files or folders that require administrator privileges, you must run it as an administrator.

If you use the method introduced here, you will no longer need to right-click on the batch file and click "Run as administrator"; you will be able to run it by double-clicking it.

table of contents

How to always run all batch files as administrator

You can also create a shortcut that always runs with administrator privileges, but here we will show you how to edit the registry.

By editing the registry, all batch files (including newly created batch files) will always be run with administrator privileges.

How to edit the registry

If you operate the registry incorrectly, it may cause problems such as the system being unable to start. Please make a backup in advance using system restore or similar, and proceed at your own risk.

To avoid panicking if your PC suddenly breaks down, it's a good idea to have a standard backup software to protect your important photos and data.

1. Press Windows key + R to open Run, type "regedit" and press Enter.

2. The Registry Editor will open, so open the following key:

HKEY_CLASSES_ROOT\batfile\shell

3. With the "shell" key selected, double-click (default) on the right to open it.

4. Enter "runas" in the Value data and click OK.

レジストリエディター
レジストリエディター

At this point, you can always run batch files (files with the .bat extension) as administrator.

Copy the following code, create a batch file, and double-click it to open it.

echo hello
pause

The User Account Control screen will appear, just as if you right-clicked the batch file and clicked "Run as administrator."

ユーザーアカウント制御
ユーザーアカウント制御

If you also want to edit files with the cmd extension, open the following key and change the following values ​​using the above as a guide:

HKEY_CLASSES_ROOT\cmdfile\shell

To revert to the original setting, right-click the edited value (default) and click Delete.

If you found this article helpful, please share it on social media.

Person who wrote this article

Driven by questions arising from my daily PC use and the desire to "do more," I have been pursuing self-study in Windows since around 2008. I am sharing the "aha!" techniques and solutions I discovered through trial and error with the sole purpose of helping you in your PC life.

View profile

Comment:

To comment

[About submissions]
We welcome any questions or information regarding the content of the article.
However, please note that content unrelated to the purpose of the article, criticism of specific individuals or organizations, offensive language,Inappropriate wordsComments containing the above may be deleted or made private without notice at the discretion of the administrator.
Please note that spam may be automatically deleted by anti-spam measures.

CAPTCHA


table of contents