Jump to content

Pass command line parameters to ShellExecute \ Runas


Go to solution Solved by super1337,

Recommended Posts

I am trying to run an application that requires UAC to elevate permissions with command line parameters...

I tried the following:

If Not IsAdmin() Then
    Global $CmdArgList

    For $i = 1 To $cmdLine[0]
        $CmdArgList = $CmdArgList & ' ' & $cmdLine[$i]
    Next

    ShellExecute(@AutoItExe & $CmdArgList, "", "", "runas")
    ProcessClose(@AutoItPID)
    Exit
EndIf

It passes all the command line parameters to shell execute so that when it runs as admin, it still has the initial parameters.

Unfortunately this does not work as it complains that Windows cannot find the exe file. Apparently it doesn't like command line parameters being passed to it.

Is there a correct way to do something like this?

Link to comment
Share on other sites

  • Solution

I just found the answer... whoops.

There is a command line option for Shell execute. The following fix works:

If Not IsAdmin() Then
    Global $CmdArgList

    For $i = 1 To $cmdLine[0]
        $CmdArgList = $CmdArgList & ' ' & $cmdLine[$i]
    Next

    ShellExecute(@AutoItExe, $CmdArgList, "", "runas")
    ProcessClose(@AutoItPID)
    Exit
EndIf
Edited by super1337
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...