Modify

Opened 8 months ago

Last modified 8 months ago

#4043 assigned Feature Request

#Directive_If_Run

Reported by: argumentum Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description (last modified by mLipok)

#Directive_If_Run
    #RequireAdmin
#Directive_If_Compile
    ; highestAvailable
#Directive_EndIf

The above is an idea. Naming is unimportant. But the concept would be very welcomed.
There is a post at https://www.autoitscript.com/forum/topic/213009-directive_if_run/ about this.

Attachments (0)

Change History (11)

comment:1 by argumentum, 8 months ago

..added in the post https://www.autoitscript.com/forum/topic/213009-directive_if_run/#findComment-1544532 that maybe #HighestAvailable is an option given that why would a user need an "if" conditional ?, just for #HighestAvailable ?, lets add #HighestAvailable then.

comment:2 by TicketCleanup, 8 months ago

Version: 3.3.16.1

Automatic ticket cleanup.

comment:3 by J-Paul Mesnage, 8 months ago

Owner: set to Jon
Status: newassigned

comment:4 by mLipok, 8 months ago

Description: modified (diff)

comment:5 by mLipok, 8 months ago

My understanding of this request lead me to this proposal:

normal/standard behavior

#RequireAdmin

only if not compiled (processed by AutoIt3.exe but omitted by Aut2exe.exe )

#RequireAdmin=1

only if compiled (processed by Aut2exe.exe but omitted by AutoIt3.exe)

#RequireAdmin=2

comment:6 by Jos, 8 months ago

Added some support to AutoIt3Wrapper for this...see linked thread.

in reply to:  5 comment:7 by Jos, 8 months ago

Replying to mLipok:

My understanding of this request lead me to this proposal:

normal/standard behavior

#RequireAdmin

only if not compiled (processed by AutoIt3.exe but omitted by Aut2exe.exe )

#RequireAdmin=1

only if compiled (processed by Aut2exe.exe but omitted by AutoIt3.exe)

#RequireAdmin=2

This was the reason the #AutoIt3Wrapper directives are created... right?:

#Autoit3Wrapper_If_Compile
    #RequireAdmin
#AutoIt3Wrapper_EndIf

comment:8 by argumentum, 8 months ago

#RequireAdmin, either compiled or not, will request RunAs admin in it's behavior.
#AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable will run as highest available only compiled.
Any script, compiled or not, can be requested to run elevated.
A #HighestAvailable would be the request am making, that would request RunAs admin if the user has admin rights but limited by UAC, or run default/limited/user if the user do not have admin rights.

The request is for the AutoIt3 product as complementary to #RequireAdmin
Then in IsAdmin(), would be nice to return an @extended, returning if the user can be admin or not ( putting the icing on the cake ).

comment:9 by argumentum, 8 months ago

...I don't know if this is useful:

Exit Test()
Func Test()
	Local $sStr = ""
	$sStr &= "IsAdmin: " & (IsAdmin() ? "Yes" : "No") & @LF & @LF
	$sStr &= "Administrator = " & _IsAdministrator() & @LF & @LF
	$sStr &= "@ScriptFullPath >" & @ScriptFullPath & "<"
	MsgBox(262144 + 64, @ScriptName, $sStr, 60)
EndFunc

Func _IsAdministrator($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

comment:10 by Jos, 8 months ago

I respond in the thread to the reported issue with #RequireAdmin as this is the request about AutoIt3.

comment:11 by argumentum, 8 months ago

Posted in the forum ( https://www.autoitscript.com/forum/topic/213009-directive_if_run/page/2/#findComment-1544584 ) changes to the wrapper that would show how #HighestAvailable would work.

Modify Ticket

Action
as assigned The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.