Jump to content
Sign in to follow this  
stgauvin

Problem in executing a compiled script without admin rights

Recommended Posts

stgauvin

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Rick
:rolleyes: Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites
stgauvin

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

Share this post


Link to post
Share on other sites
Jos

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

Have you removed the #RequireAdmin ?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
stgauvin

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

Share this post


Link to post
Share on other sites
MHz

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

Share this post


Link to post
Share on other sites
stgauvin

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

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.