Jump to content

Anti-#RequireAdmin?


Recommended Posts

Hello, everyone.

I have a longish system setup and configuration AutoIt script that needs to run in fully automatic mode (no user intervention except for the moment the script is started). Parts of the script need administrator privileges, but other parts must be run under the current user account, and these parts are mixed. My impression so far is that #RequireAdmin cannot be reversed when I no longer need it in my script. So everything there is runs with admin privileges, and I get invalid results.

Should I try to use things like RunAs, then, or maybe divide the script into many small scripts and run those from an external batch file, so that #RequireAdmin won't spoil the execution of non-admin parts? Is there a better way?

Any ideas are appreciated.

Thanks.

Link to comment
Share on other sites

#RequireAdmin will check to see if the user launching the script is admin, if they are not you'll be prompted for a user account who is. If none is provided the script terminates.

What you're looking for is IsAdmin to do checks during a script. You'll want to use RunAs to elevate permissions.

If IsAdmin() Then RunAs.... etc..

Edited by ZacUSNYR
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...