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.
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.
- How to create and restore a system restore point
- How to open and back up the Registry Editor
- Windows 11/10 Registry Basics: Concept, How to Open, and Internal Structure
- How to Take Ownership and Change Permissions in Windows 11 Registry
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.

Comment: