Jump to content
Sign in to follow this  
DatMCEyeBall

#requireadmin

Recommended Posts

DatMCEyeBall

Just something I've been wondering, is it possible to do something like this:

If Not IsAdmin() Then
    #requireadmin
EndIf

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
Jos

If the user doesn't have admin rights, the script elevates it's permissions?

Correct ... the script is reran in Admin mode when it isn't yet.

So what exactly are you looking for because your initial question doesn't make any sense for a logic point of view?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
JLogan3o13

So as Jos is trying to point out, since the #RequireAdmin reruns the entire script in Admin mode, think about why this wouldn't work.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
DatMCEyeBall

So is there another approach to this?

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
JLogan3o13

Again, look at what Jos is asking - we need more information on exactly what you are trying to do in order to make suggestions. Post your script or a reproducer, instead of asking us guess ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
DatMCEyeBall

I got it, If I put #requireadmin at the beginning of my script it only requests permission if the user doesn't have the correct permissions.

The point was I wanted to learn something, not make something.

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
Morthawt

You can't use #requireadmin within a conditional statement. I had an idea long ago to make a script once that would only ask for admin mode if a particular action was needed, else stay with user access but it didn't work. Either your script will have admin or it won't.

Share this post


Link to post
Share on other sites
AdamUL

To conditionally elevate your whole script, you could use the following.

If Not IsAdmin() Then
    If @Compiled then
        ShellExecute(@ScriptFullPath, "", @ScriptDir, "runas")
    Else
        ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '"', @ScriptDir, "runas")
    EndIf
    Exit
EndIf

Have a look at this >thread on elevating and delevating your script.  

 

Adam

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  

×