Sign in to follow this  
Followers 0
vanquish12

Anti-#RequireAdmin?

2 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#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

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