corgano Posted September 7, 2010 Share Posted September 7, 2010 I want The script to only use administrator on cretin systems, to this effect. If @OSType = "Vista" OR @OSType = "2008" OR @OSType = "2008R2" OR @OSType = "Win7" Then #requireadmin EndIf This will allways ask for admin. I only want it to require admin on vista, win 7, and win 2008 systems. Is this posible with #requireadmin? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
corgano Posted September 13, 2010 Author Share Posted September 13, 2010 Does no one know or is it not possible? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
trancexx Posted September 13, 2010 Share Posted September 13, 2010 (edited) Of course it's not possible. Strange thing is you even asking. ←If Not IsAdmin() Then Switch @OSVersion Case "Vista", "2008", "2008R2", "WIN_7" If @Compiled Then ShellExecute(@AutoItExe, "", "", "runas") Exit Else ShellExecute(@AutoItExe, ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '"', "", "runas") Exit EndIf EndSwitch EndIf MsgBox(64, "", IsAdmin()) Edited September 13, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 13, 2010 Share Posted September 13, 2010 (edited) Use #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator And make sure you compile with AutoIt3Wrapper. And don't use the regular #RequireAdmin. Edited September 13, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
corgano Posted September 13, 2010 Author Share Posted September 13, 2010 So I put this at the start of the script or in the if statement? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
adam162 Posted September 13, 2010 Share Posted September 13, 2010 At the start of the script Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 14, 2010 Share Posted September 14, 2010 Technically you can put it anywhere in your script. It doesn't matter because it's not actually code. Also, #RequireAdmin doesn't happen when the script parser reads the line. It happens before the script actually starts which is why your If statement did nothing. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 14, 2010 Share Posted September 14, 2010 Use #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator And make sure you compile with AutoIt3Wrapper. And don't use the regular #RequireAdmin. Out of curiosity, how does this differ from the normal #requireadmin preprocessor command? Especially in regards to using it on Vista or Win7? I understand that this will only be used by the AutoIt3Wrapper at compile time and not when run as a script, but does it actually have a different effect when it's compiled than #requireadmin? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 14, 2010 Share Posted September 14, 2010 Instead of AutoIt rerunning itself if it isn't running as an administrator, AutoIt doesn't check at all. The wrapper's option changes the executable manifest so Windows will give it the "admin badge" and call the UAC dialog when it needs to. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 14, 2010 Share Posted September 14, 2010 I understand now, very handy to know. Thanks for the information. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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