stgauvin Posted June 14, 2007 Share Posted June 14, 2007 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 More sharing options...
Developers Jos Posted June 14, 2007 Developers Share Posted June 14, 2007 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 More sharing options...
Rick Posted June 14, 2007 Share Posted June 14, 2007 (edited) Edited June 14, 2007 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
stgauvin Posted June 14, 2007 Author Share Posted June 14, 2007 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 More sharing options...
Developers Jos Posted June 14, 2007 Developers Share Posted June 14, 2007 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 More sharing options...
stgauvin Posted June 14, 2007 Author Share Posted June 14, 2007 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 More sharing options...
MHz Posted June 14, 2007 Share Posted June 14, 2007 (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,SteveLook 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. Edited June 14, 2007 by MHz Link to comment Share on other sites More sharing options...
stgauvin Posted June 14, 2007 Author Share Posted June 14, 2007 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.Thanks for the explanation.Steve Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now