Jump to content

#requireadmin issues


corgano
 Share

Recommended Posts

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

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 by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

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 Gude
How 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

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 Gude
How 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

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