Modify

Opened 3 weeks ago

Last modified 3 weeks 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 Changed 3 weeks ago by argumentum

..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 Changed 3 weeks ago by TicketCleanup

  • Version 3.3.16.1 deleted

Automatic ticket cleanup.

comment:3 Changed 3 weeks ago by Jpm

  • Owner set to Jon
  • Status changed from new to assigned

comment:4 Changed 3 weeks ago by mLipok

  • Description modified (diff)

comment:5 follow-up: Changed 3 weeks ago by 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

comment:6 Changed 3 weeks ago by Jos

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

comment:7 in reply to: ↑ 5 Changed 3 weeks ago by Jos

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 Changed 3 weeks ago by argumentum

#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 Changed 3 weeks ago by argumentum

...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 Changed 3 weeks ago by Jos

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

comment:11 Changed 3 weeks ago by argumentum

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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as assigned The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.