Start Batch File As Administrator

Learning has never been so easy!

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. I have a batch file that executes certain commands and one of these commands requires admin privilege. When I place this file in the startup folder the command fails. Right clicking on it and setting it to run as admin doesn't work. I am told scripts can be programmed to run something else as admin and I am looking for ideas on that.

write a batch file to open device manager as administrator

3 Steps total

Step 1: Save as .bat

runas /user:ComputernameUser 'cmd.exe /c 'start compmgmt.msc'

echo off
pause

File

Start Batch File As Administrator Linux

Device_manager.txt

Run Batch File As Administrator Without Uac Prompt

Step 2: Another example

runas /user:[email protected] 'cmd.exe /c 'start compmgmt.msc'

Step 3: Link

https://stackoverflow.com/questions/22574277/trying-to-write-a-batch-file-to-open-programs-as-an-administrator

Start Batch File As Administrator Windows 10

References

  • Reference Link

2 Comments

  • Jalapeno
    CamTheHam Jul 23, 2019 at 10:20am

    Very useful, been wondering how to do this lately. Thanks!

  • Serrano
    shiraza Aug 25, 2019 at 01:19pm

    good little script
    i have not tried it yet but I wonder if I get the UAC Prompt ?