How do I run a batch file from another batch file with administrator rights?
I have tried the RUNAS command, but it requires the administrator password.
I am searching for an alternative for running a batch file by right clicking on it and running as an administrator. I want to automate it from another batch file.
Yes, you're able to run a batch file with administrative rights.
Step 1: Open the Start Menu and type command prompt on the search bar. Step 2: Select Command Prompt and then on the right-side panel click on Run as Administrator. Step 3: The command prompt opens with the title Administrator: Command Prompt. Type the batch file path and name and press Enter.
So instead You just right click on your "file. bat - shortcut" then go to ->Properties->Shortcut tab -> Advanced and there you can click Run as administrator. After that, You can execute the shortcut.
Put each line in cmd or all of theme in the batch file:
@echo off if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b) "Put your command here"
it works fine for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With