TravisC Posted March 28, 2008 Share Posted March 28, 2008 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 More sharing options...
rudi Posted March 29, 2008 Share Posted March 29, 2008 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 More sharing options...
Swift Posted March 29, 2008 Share Posted March 29, 2008 Why not just put #RequireAdmin, because XP users don't get the prompt, only VISTA. Link to comment Share on other sites More sharing options...
monoceres Posted March 29, 2008 Share Posted March 29, 2008 This should NOT be fact!Not sure, but isn't it so that directives starting with '#' will just be extracted from the code and executed directly at startup. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
TravisC Posted March 29, 2008 Author Share Posted March 29, 2008 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 More sharing options...
monoceres Posted March 29, 2008 Share Posted March 29, 2008 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 More sharing options...
TravisC Posted March 29, 2008 Author Share Posted March 29, 2008 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 More sharing options...
MHz Posted March 29, 2008 Share Posted March 29, 2008 how can i make my script #requireadmin for vista only? I tried#RequireAdmin is a directive. It is read before the script starts execution so conditional runtime code has no effect on it. Link to comment Share on other sites More sharing options...
rudi Posted March 29, 2008 Share Posted March 29, 2008 #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 More sharing options...
daslick Posted March 29, 2008 Share Posted March 29, 2008 It does seem that way. Maybe an alternative would be a conditional self-runas command? Link to comment Share on other sites More sharing options...
TravisC Posted March 29, 2008 Author Share Posted March 29, 2008 It does seem that way. Maybe an alternative would be a conditional self-runas command?how would i do that? Link to comment Share on other sites More sharing options...
JohnMC Posted March 29, 2008 Share Posted March 29, 2008 ; 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. https://johnscs.com Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now