Jump to content

#requireadmin


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

Probably in the next Beta?

Think about this for a moment. What exactly does that statement do?

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

Link to comment
Share on other sites

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

"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

Link to comment
Share on other sites

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I want to enable admin rights in the middle of script execution.

"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

Link to comment
Share on other sites

  • Moderators

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.

"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

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

Link to comment
Share on other sites

  • Moderators

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 ;)

"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

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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...