dolphins Posted February 19, 2016 Share Posted February 19, 2016 Hi, I have an AutoIt program that is using "Run" to start another AutoIt program that has #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator set (the caller doesn't have Admin rights). This doesn't work (at leat I wasn't able to make it work). So I called a bat file and that bat file started the 2nd AutoIt program. This works. But one can see the black Dos Box on the Screen. If I this @SW_HIDE the black dos box doesn't appear but also the UAC prompt doesn't come into front, it is in the Background and the user Need to click at it to see that Dialog. That is not comfortable for the user. Any way to not Show that black dos box and have the UAC prompt on top of the Screen? Or is it possible to Run an AutoIt program with #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator from an AutoIt program that doesn't have #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator. Any other suggestions? Regards dolphins Link to comment Share on other sites More sharing options...
jdelaney Posted February 20, 2016 Share Posted February 20, 2016 I'd run with full rights as a scheduled task. You can invoke that without admin, but because the credentials are linked with the task, it runs without UAC. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
dolphins Posted February 20, 2016 Author Share Posted February 20, 2016 The UAC itself is not the problem. With the bat-file I just want that the UAC comes on top of all windows, but it doesn't when I use @SW_HIDE. Link to comment Share on other sites More sharing options...
Juvigy Posted February 20, 2016 Share Posted February 20, 2016 You can use autoit functions to bring the UAC window on TOP. Otherwise I havent tested , but i think if caller script is with admin rights - then the subscript will have admin rights too. Link to comment Share on other sites More sharing options...
jguinch Posted February 20, 2016 Share Posted February 20, 2016 If I understand your problem, you should use ShellExecute instead of Run Doniel 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
dolphins Posted February 20, 2016 Author Share Posted February 20, 2016 The caller script does not have admin rights. Well, not sure about ShellExecute, since I don't want to give other credentials when not necessary. Also I don't know the password of the current user. So if I understand ShellExecute right, it doesn't fit my needs. The suggestion to use AutoIt to bring the UAC window to the top is not possible when I start the 2nd AutoIt program from a bat-file, isn't it? Since in that moment there is no AutoIt program running. Link to comment Share on other sites More sharing options...
dolphins Posted February 20, 2016 Author Share Posted February 20, 2016 Oh, just got an idea. Right now I quit the caller program after calling the bat-file. Maybe after calling the bat file, I can look for the UAC window, bring it to top, and then exit the caller program. Hmmmm. Link to comment Share on other sites More sharing options...
AoRaToS Posted February 20, 2016 Share Posted February 20, 2016 (edited) Hello, can you post some code? This should work, it works for me with a program I've made. Does the second program, the one being called, have #RequireAdmin in? Edited February 20, 2016 by AoRaToS s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3 Link to comment Share on other sites More sharing options...
dolphins Posted February 20, 2016 Author Share Posted February 20, 2016 Yes, the 2nd has that. I can post some code on Monday. Link to comment Share on other sites More sharing options...
dolphins Posted February 22, 2016 Author Share Posted February 22, 2016 (edited) Ok, here some code. I made the sample code as short as possible. Main program: expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> #include <string.au3> #include <Date.au3> _Main() Func _Main() Func1() EndFunc Func Func1() $Form1 = GUICreate("Main", 800, 550) $btnUpdate = GUICtrlCreateButton("Update", 35, 220, 145, 33) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent($btnUpdate, "Update_Button") GUISetState(@SW_SHOW, $Form1) While 1 $msg = GUIGetMsg() Select Case $msg = $btnUpdate GUISetState(@SW_HIDE, $Form1) Sub_Update() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd GUISetState(@SW_SHOW, $Form1) EndFunc Func Sub_Update() $zwi = @ScriptDir & "\upd.bat " $pid = Run($zwi, @ScriptDir) If $pid = 0 And @error <> 0 Then MsgBox(16,"Error", "Update.exe error;" & @error) Else Exit EndIf EndFunc Sub program: expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> #include <string.au3> _Main() Func _Main() $FormSub = GUICreate("Sub", 680, 100, 200, 50) GUISetState(@SW_SHOW, $FormSub) GUICtrlCreateLabel("some info ...", 35, 25, 650, 28) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Sub_Start() GUIDelete($FormSub) EndFunc Func Sub_Start() MsgBox(0, "Sub", "Update is going on ...") $zwi = @ScriptDir & "\Main.exe " $retCode = Run($zwi, @ScriptDir) If $retCode = "0" And @error <> 0 Then MsgBox(16, "Error Sub", "Some error text;" & @error) EndIf Exit EndFunc Upd.bat: @echo off Start sub.exe The main program is compiled with 3.3.8.1, the Sub program is compiled with 3.3.14.0 The main program has the User GUI. In this sample I made a button to start the Update (in the real main, it checks for date and Version versus a file in the Internet). This button removes the User GUI and starts Upd.bat. Upd.bat start Sub.exe. Sub.exe Shows a running message and after the update is done calls main.exe again. When the Upd.bat starts Sub.exe the UAC Dialog appears, but in Background and not on top of all Windows. - How can I bring the UAC Dialog to top without showing the black dos Box? - Or how can I start the Sub.exe and showing the UAC Dialog asking for admin rights without giving new credentials, when the current user has admin rights (when the user has no admin rights it should prompt for user Name and Password with admin rights) Edited February 22, 2016 by dolphins Link to comment Share on other sites More sharing options...
Juvigy Posted February 22, 2016 Share Posted February 22, 2016 Winactivate() should be the easiest way to activate the UAC. You should need no BAT file - just use shellexecute the second autoit exe file and there will be no cmd black box. Link to comment Share on other sites More sharing options...
dolphins Posted February 22, 2016 Author Share Posted February 22, 2016 Thanks, I got it working now with ShellExecute. Somehow I thought I had to give new credentials when using ShellExecute like RunAsWait for example, but that is nonsense. It works fine now. Thanks a lot ! Link to comment Share on other sites More sharing options...
jguinch Posted February 22, 2016 Share Posted February 22, 2016 4 hours ago, dolphins said: Thanks, I got it working now with ShellExecute. #5 gave you the answer, two days ago Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
dolphins Posted February 24, 2016 Author Share Posted February 24, 2016 Correct! I had a wrong information about ShellExecute in my head, so I didn't take a look in the help immediately. After I took that hurdle, it was easy going Link to comment Share on other sites More sharing options...
Doniel Posted February 8, 2022 Share Posted February 8, 2022 On 2/20/2016 at 1:11 PM, jguinch said: If I understand your problem, you should use ShellExecute instead of Run Thanks, that also solved my problem! Now I can start a non-elevated script and in there an elevated script that contains an #RequireAdmin ! “It is only when a mosquito lands on your testicles that you realize there is always a way to solve problems without using violence.” ― Confucius 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