Sign in to follow this  
Followers 0
wslh

How to handle different behavior if user can/can't escalate privileges with #RequireAdmin?

5 posts in this topic

#1 ·  Posted (edited)

Hi,

I would like to run my AutoIt script in two scenarios with different behaviour:

i) With #RequireAdmin

ii) Without #RequireAdmin if user can't escalate privileges.

a) How can I do that since the RequireAdmin affects the .exe manifest?

:graduated: And also how can I verify if the user can escalate privileges?

I was thinking in packing two exes for (a), but don't know how to do (:(. There is other way to accomplish it?

Thanks,

wslh

Edited by wslh

Share this post


Link to post
Share on other sites



IsAdmin() maybe.

I don't think so. If you haven't escalated privileges it returns false. And if the script was compiled with #RequireAdmin it can't run without Admin privileges.

Share this post


Link to post
Share on other sites

I had it in my head that this would work.

If IsAdmin() Then
    #RequireAdmin
EndIf

While 1
    sleep(20)
WEnd

Of course though, it does not.

The operating system already handles this with the manifest level "highestAvailable" - so use this in your script:

#AutoIt3Wrapper_res_requestedExecutionLevel=highestAvailable

It will prompt for admin if the user can give it, otherwise it will run as a regular user. Will also selectively display the shield. (#RequireAdmin relaunches as admin, so it does not display the shield).

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0