Jump to content

#requireadmin for Vista ONLY


Recommended Posts

how can i make my script #requireadmin for vista only? I tried

If @OSVersion = "WIN_VISTA" Then
    #RequireAdmin
EndIf

but other os's still get prompted for an admin password. how can i make it where only vista users are prompted because of UAC and xp/2k can run on limited accounts?

Link to comment
Share on other sites

Hi.

how can i make my script #requireadmin for vista only? I tried

If @OSVersion = "WIN_VISTA" Then
    #RequireAdmin
EndIf

but other os's still get prompted for an admin password.

This should NOT be fact!

Put these lines on top of your code:

If @OSVersion = "WIN_VISTA" Then
    #RequireAdmin
Else
    MsgBox(64,"Not Vista","This isn't Vista, this is " & @OSVersion)
EndIf

Exit

If it works, remove the "exit". If it then again does nonsense, you'll propably have another #RequireAdmin somewhere in your code.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Why not just put #RequireAdmin, because XP users don't get the prompt, only VISTA.

No, it prompts for 2k and xp also.

"This function was primarily aimed at allowing AutoIt scripts to work correctly with Windows Vista User Account Control (UAC) (However, will also work on Windows 2000 and Windows XP)."

Link to comment
Share on other sites

If my above post was right the only way to fix this would be to have 3 scripts, one with the #RequireAdmin keyword and one without, then a third which ran the other scripts according to windows versions

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Hi.

This should NOT be fact!

Put these lines on top of your code:

If @OSVersion = "WIN_VISTA" Then
    #RequireAdmin
Else
    MsgBox(64,"Not Vista","This isn't Vista, this is " & @OSVersion)
EndIf

Exit

If it works, remove the "exit". If it then again does nonsense, you'll propably have another #RequireAdmin somewhere in your code.

Regards, Rudi.

How is that code any different from the code i already said i tried?
Link to comment
Share on other sites

#RequireAdmin is a directive. It is read before the script starts execution so conditional runtime code has no effect on it.

so there is no way to define CONDITIONAL directives? :)

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

; This example will rerun itself with admin rights on using a local account

; Note on Vista this may not work as even though the user is admin it may

; not be elevated even after the RunAs call. In that case use #RequireAdmin

; at the top of the script.

; Are we already admin?

If Not IsAdmin() Then

RunAsSet('USER', @Computername, 'PASSWORD')

Run('"' & @AutoItExe & '"' & ' "' & @ScriptFullPath & '"', @WorkingDir)

Exit

EndIf

MsgBox(0, 'Message', 'Now running with admin rights.')

i was never aware but from what the help file says basicly vista may or may not run a program with elevated permisions when using runasset, i cant think of anyway around this, but im very interested so im going to keep thinking.

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