argumentum Posted July 23 Author Posted July 23 This is my test script: ;~ #RequireAdmin #HighestAvailable Exit Test() Func Test() Local $sStr = "" $sStr &= "IsAdmin: " & (IsAdmin() ? "Yes" : "No") & @LF & @LF $sStr &= "IsAdminUser = " & _IsAdminUser() & @LF & @LF $sStr &= "@ScriptFullPath >" & @ScriptFullPath & "<" ConsoleWrite($sStr & @CRLF) MsgBox(262144 + 64, @ScriptName, $sStr, 60) EndFunc Func _IsAdminUser($sUser = @UserName, $sCompName = ".") ; https://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/ Local $aCall = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sCompName, "wstr", $sUser, "dword", 1, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, False) Local $fPrivAdmin = DllStructGetData(DllStructCreate("ptr;ptr;dword;dword;ptr;ptr;dword;ptr", $aCall[4]), 4) = 2 DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aCall[4]) Return $fPrivAdmin EndFunc And these are the changes to Autoit3Wrapper: ... ; Show Consolemessage about running a script that required elevated rights not displaying anuy console messages If StringRegExp($I_Rec, "^\h*#HighestAvailable") And _IsAdminUser() And Not IsAdmin() Then $Shell_RQA_Diff = 2 If StringRegExp($I_Rec, "^\h*#RequireAdmin") And Not IsAdmin() Then $Shell_RQA_Diff = 1 EndIf ... __ConsoleWrite("->" & @HOUR & ":" & @MIN & ":" & @SEC & ' Your script requires Admin rights while SciTE is at normal level -> Starting new AutoIt3Wrapper with ' & ($Shell_RQA_Diff = 2 ? '#HighestAvailable' : '#RequireAdmin') & ' to run the script.' & @CRLF) Local $TmpPid = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $temp_Script & '"') ; Check for the script to start ; wait for the tempscript to shell AutoIt3Wrapper to finish and check the IPC for its successfull startup ProcessWaitClose($TmpPid) ... #EndRegion ### FMIPC ### Func _IsAdminUser($sUser = @UserName, $sCompName = ".") ; https://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/ Local $aCall = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sCompName, "wstr", $sUser, "dword", 1, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, False) Local $fPrivAdmin = DllStructGetData(DllStructCreate("ptr;ptr;dword;dword;ptr;ptr;dword;ptr", $aCall[4]), 4) = 2 DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aCall[4]) Return $fPrivAdmin EndFunc Not many changes. Used #HighestAvailable as the keyword as it is the keyword I used in trac. @Jos, this has the functionality I was looking for. I only did the run GUI from SciTE. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted July 23 Developers Posted July 23 (edited) I do not understand yet what this change accomplishes or gives extra. So what does this solve that isn't there yet? Edited July 23 by Jos 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.
argumentum Posted July 23 Author Posted July 23 ...is a matter of experiences I guess. Usually you have either asInvoker or requireAdministrator. But there is highestAvailable: "The application runs at the highest permission level that it can. If the user who starts the application is a member of the Administrators group, this option is the same as level='requireAdministrator'. If the highest available permission level is higher than the level of the opening process, the system prompts for credentials." What I posted does that highestAvailable, that unless you find yourself needing it, is kind of inconceivable. But again, if you had that situation, there's no way around it. Is basically a: If StringRegExp($I_Rec, "^\h*#HighestAvailable") And _IsAdminUser() And Not IsAdmin() Then $Shell_RQA_Diff = 2 If the user is part of the admin group, make it #RequireAdmin, else, asInvoker. That is what it does and is not there, ..unless it was there and I missed it ?, and if so, please tell me how Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted July 23 Developers Posted July 23 (edited) So this is only when running a script with Autoit3Wrapper. ...and still do not understand in which exact situation this is required, where a simple #requireadmin isn't the right choice. EDIT: So is the "#HighestAvailable" anticipating on it getting implemented in AutoIt3 as I don't see it doing anything right now? Edited July 23 by Jos 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.
Developers Jos Posted July 23 Developers Posted July 23 To make this whole discussion void: When you really want to finetune any execution level you can simply use pragma: Quote Directive Parameters Description Example Out Filename Sets the file name of the compiled executable. #pragma compile(Out, AutoIt_Example.exe) Icon Filename Sets the compiled executable icon. #pragma compile(Icon, \..\back2.ico) ExecLevel none, asInvoker, highestAvailable, requireAdministrator Sets the execution level in the compiled executable manifest. #pragma compile(ExecLevel, highestavailable) 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.
argumentum Posted July 23 Author Posted July 23 12 minutes ago, Jos said: So this is only when running a script with Autoit3Wrapper. Yes. 12 minutes ago, Jos said: ...and still do not understand in which exact situation this is required, where a simple #requireadmin isn't the right choice. That is why I said that is a matter of experience with such. In my case is very much needed. AutoIt3 has asInvoker(default) and requireAdministrator(via #RequireAdmin) but is missing the "highestAvailable". Autoit3Wrapper has them all but for compile only. The code that I present is something that should be there, but then again, is a matter of experiences with that uncommon highestAvailable. Am not a purist in any sense but I am a "completist" The #HighestAvailable is something that should have been there ( in AutoIt and the wrapper ) since always for all functions. But I understand the lack of .... experiences with such, as to never have come up. 2 minutes ago, Jos said: To make this whole discussion void: When you really want to finetune any execution level you can simply use pragma: Nope, that "#pragma compile(ExecLevel, highestavailable)" is for compile only. There is currently no recourse for a #HighestAvailable situation. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted July 23 Developers Posted July 23 3 minutes ago, argumentum said: Nope, that "#pragma compile(ExecLevel, highestavailable)" is for compile only. true! 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.
argumentum Posted July 23 Author Posted July 23 28 minutes ago, Jos said: EDIT: So is the "#HighestAvailable" anticipating on it getting implemented in AutoIt3 as I don't see it doing anything right now? Chronology right ?. Not sure if posting this comment is out of chronological sense but, here it goes: If #RequireAdmin didn't exist in AutoIt3, the wrapper would behave as if it did. Moreover, it has to, as otherwise it would not anticipate that could not communicate with SciTE due to not catching that. Will be the same with #HighestAvailable. The wrapper will have to anticipate it for the same reasons. So if it gets implemented, the code was there, and if is not implemented yet, ..the code is here to behave all the same. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted July 23 Developers Posted July 23 6 minutes ago, argumentum said: So if it gets implemented, the code was there, and if is not implemented yet, ..the code is here to behave all the same. I will look at it If/when this ever gets implemented, as I have slight doubts it will ever happen. 😉 argumentum 1 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.
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