Sign in to follow this  
Followers 0
stgauvin

Problem in executing a compiled script without admin rights

8 posts in this topic

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



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

#3 ·  Posted (edited)

:rolleyes: Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

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  
Followers 0