Jump to content

Require Admin Design


RC86
 Share

Recommended Posts

Morning! I've searched for a definitive answer on the forums on this but can't find one so here goes.  I need admin for one of my functions so I'm using #RequireAdmin.  I then noticed that regardless of that function being used or admin actually being required, the program pops up and requires admin all of the time.

Is this the way it's designed and is there a way around it so that I can launch my program as normal until admin is required, then and only then prompt the user to run the program as admin?

The only solution I could think of is to produce 2 executables and do something like:

$adminrequired = 1
If($adminrequired = 1) Then
    Run(Run first executable which includes #RequireAdmin)
Else
    Run(Run second identical executable without #RequireAdmin)
EndIf

Obviously I'd rather keep to making a single executable rather than having 2 or 3!

Thanks

Link to comment
Share on other sites

  • Moderators

@RC86  Directives like #RequireAdmin are not conditional; AutoIt looks for them and executes before running the script. You can use something like _Security_CreateProcessWithToken  (check the help file) as a work around. It actually does the opposite; you run your script elevated and this allows you to create a process that is non-elevated.

Also, there are a couple of folks who have done some work on elevating and reducing rights on demand using UAC. Check out the thread below for some of the work done my Kafu and Ascend4nt

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

×
×
  • Create New...