Jump to content

Problem in executing a compiled script without admin rights


Recommended Posts

Hi,

I need to create a script that use the RunAsSet command to lauch a setup program that require admin right. When I build (compile) the script to create a .exe, when a simple user try to lauch the .exe autoit script, Windows XP SP2 ask the user to enter a admin user (same window of the runas gui command).

When a admin user lauch the .exe compiled script, the script run correctly.

Here is the script:

#RequireAdmin

Dim $Question

$Question = MsgBox (4, "Installation de Microsoft Streets & Trips 2007", "Voulez-vous installer Microsoft Streets & Trips 2007 ?")

If $Question = 6 Then

RunAsSet("administrateur", @Computername, "aufeu", 0)

If @error Then Exit

Run("Setup_ST.exe", @ScriptDir, @SW_MAXIMIZE )

Else

Exit

EndIf

Steve

Link to comment
Share on other sites

  • Developers

Try:

Dim $Question
$Question = MsgBox(4, "Installation de Microsoft Streets & Trips 2007", "Voulez-vous installer Microsoft Streets & Trips 2007 ?")
If $Question = 6 Then
    RunAsSet("administrateur", @ComputerName, "aufeu", 0)
    If @error Then Exit
    Run(@ScriptDir & "\Setup_ST.exe", @ScriptDir, @SW_MAXIMIZE)
EndIf

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I have test your modification, but I have the same problem when I launch it.

Try:

Dim $Question
$Question = MsgBox(4, "Installation de Microsoft Streets & Trips 2007", "Voulez-vous installer Microsoft Streets & Trips 2007 ?")
If $Question = 6 Then
    RunAsSet("administrateur", @ComputerName, "aufeu", 0)
    If @error Then Exit
    Run(@ScriptDir & "\Setup_ST.exe", @ScriptDir, @SW_MAXIMIZE)
EndIf
Link to comment
Share on other sites

  • Developers

I have test your modification, but I have the same problem when I launch it.

Have you removed the #RequireAdmin ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Have you removed the #RequireAdmin ?

No,

I have remove it and it`s work. But if I can run the same script on a Vista with UAC enable, how I can do that, because #RequireAdmin is required with Vista and UAC ?

Thanks,

Steve

Link to comment
Share on other sites

No,

I have remove it and it`s work. But if I can run the same script on a Vista with UAC enable, how I can do that, because #RequireAdmin is required with Vista and UAC ?

Thanks,

Steve

Look at it this way. #RequireAdmin forces AutoIt to ask for the Runas prompt to show and give permission for your script to run as admin. Then you had a RunAsSet() being executed in your script when it is already running as admin. So you may find that one was conflicting with the other and causing it to fail.

With Vista in mind, you can choose to use #RequireAdmin or you can choose RunAsSet() (note: the later affects Run, RunWait and ShellExecute only). You should not have the need to use both #RequireAdmin and RunAsSet() and as you found out, it can cause failure to use both.

:rolleyes:

Edited by MHz
Link to comment
Share on other sites

Look at it this way. #RequireAdmin forces AutoIt to ask for the Runas prompt to show and give permission for your script to run as admin. Then you had a RunAsSet() being executed in your script when it is already running as admin. So you may find that one was conflicting with the other and causing it to fail.

With Vista in mind, you can choose to use #RequireAdmin or you can choose RunAsSet() (note: the later affects Run, RunWait and ShellExecute only). You should not have the need to use both #RequireAdmin and RunAsSet() and as you found out, it can cause failure to use both.

:rolleyes:

Thanks for the explanation.

Steve

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...