Jump to content
Sign in to follow this  
alexxx73

Run a vbs as admin

Recommended Posts

alexxx73

Hello everyone.

The first thing I want is to ask forgiveness for my English, but I'm Spanish.

Regarding the question, I searched around the forum, but I have not found how to do it.

I use AutoIT3 and what I want is to launch a vbs with administrator permissions.

I use this ...

Runas ($sUserName, @ComputerName, $sPassword, 0, "cscript.exe " & @ScriptDir & "\script.vbs")

But it does not work.

Any help?

Thanks and gracias!! :-)

Share this post


Link to post
Share on other sites
alexxx73

VBScript UAC elevation

Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "notepad.exe", "" , "", "runas", 1
Thanks, i use it, but ask me the user and the pass and then open notepad

I want to create a .exe who launch a vbs with admin permission. (The user and pass should be inside the .exe)

Thanks a lot!

Edited by alexxx73

Share this post


Link to post
Share on other sites
DCCD

like this!

#Include <WinAPI.au3>
;
$File = "yourfile.vbs"
$App  = "WScript.exe "
;
Local $sUserName = "User"
Local $sPassword = "Passwd"
;
RunAs($sUserName, @ComputerName, $sPassword, 0, $App & $File, @SystemDir)
;
MsgBox(0,"last message!!",_WinAPI_GetLastErrorMessage())

Share this post


Link to post
Share on other sites
alexxx73

its does not work...

:_(

thanks for try

any idea?

Share this post


Link to post
Share on other sites
alexxx73

its does not work...

:_(

thanks for try

any idea?

I have the solution!!!

The problem was with "" and '

This works....

Local $sUserName = "User"
Local $sPassword = "Passwd"

RunAs($sUserName, @ComputerName, $sPassword, 0, 'wscript.exe "' & @ScriptDir & '\script.vbs"')

Regards

Edited by alexxx73

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.