Jump to content

Run a vbs as admin


Recommended Posts

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!! :-)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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())
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...