Jump to content
Sign in to follow this  

Copy files as domain user & install program as Admin

Recommended Posts



Just a reference post for those who want to use Autoit to run executable as administrator

I was trying to rewrite an old autoit script from using RunAsSet() & switch to Run() / RunWait() as the newer AutoIt deprecated RunAsSet()

The following example helps you to kill all the Excel process on the machine

then map network drive as another user & copy files to where your script relies

This is not meant to be secure / just a dirty fix for your environment~

I am sure if you search further, you would find much better script the following~~

Hope this help some admins around

$sUserName = 'Administrator'

$sPassword = 'Adminpassword'

$ExePath = "T:\Admin.exe"

If IsAdmin() Then

$Answer = MsgBox(4100, "My App Installer", "Do you want to close Excel?",10)

If $Answer =6 Then

;Kill all excel.exe process

ShellExecute("taskkill.exe", "/f /im excel.exe",@SW_HIDE)

; Map repository drive with domain user's credentials, then copy Admin.exe to @scriptDir

ShellExecute('cmd.exe', '/c net use T: \\fs01\repo /user:mydomain\user01 user01password && copy '& $ExePath & " " & @ScriptDir )

;Execute the copied program as administrator

RunWait("Admin.exe",@ScriptDir )




;The following command rerun the script as Admin, so the user could run the executable with admin privilege without knowing the password

RunAs($sUserName, @ComputerName, $sPassword, 0, @AutoItExe & ' /RunAs', 'C:\WIndows\System32', @SW_HIDE)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.