Elevate compiled script exe without UAC dialog

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 665
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Elevate compiled script exe without UAC dialog

Post by Grovkillen » Wed Apr 01, 2020 6:15 pm

If you have a user account with admin rights or if you want to use the admin account you can do so and not have the UAC dialog pop-up.

Code: Select all

Let>EXE_PATH=cmd.exe
RunProgram>runas /user:%COMPUTER_NAME%\admin "%EXE_PATH%"
Wait>1
Send>SuP3rP455W0rD
Press>Enter
The above code will open the command tool as the "admin" account. The wait 1 is just used to wait for the command line terminal to show before sending the user account's password and press enter. You now got a elevated cmd.exe.

This would be used to have your script selfcheck if it's running with admin rights, if not execute self like this.

Your computers admin account is easily found by running "compmgmt.msc" from the search (Win+R). I usually rename my administrator account to "admin" and set the password to a default one.
Let>ME=%Script%

Running: 15.0.18
version history

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts