Shark007 Posted April 28, 2009 Posted April 28, 2009 My GUI contains several different functions. functions that write to HKCU should not be invoked using admin privliges. while others in the GUI call regsvr32 which must use admin privliges. Is it possible to have a function call #RequireAdmin only as needed? Currently, no matter where I place #RequireAdmin, even in an IF statement, the GUI automatically starts off requesting admin privliges.
Moderators Melba23 Posted April 28, 2009 Moderators Posted April 28, 2009 Shark007, To the best of my knowledge (backed up by a quick search!), directives are not conditional - if they appear anywhere in the script, they are acted upon! Sorry. :-( M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Yashied Posted April 28, 2009 Posted April 28, 2009 Maybe use IsAdmin()?. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted April 28, 2009 Posted April 28, 2009 You can only elevate at the process level. It's not possible to elevate at the function or even thread level. You can use ShellExecute() with the runas verb to simulate the behavior of #RequireAdmin. Depending on the complexity of the statement you may be able to invoke @AutoItExe via ShellExecute() to prompt for elevation and use the single-line command feature to run a single line elevated. However, keep in mind, if you have multiple such commands you will annoy the user with all the UAC prompts.
Shark007 Posted April 28, 2009 Author Posted April 28, 2009 (edited) Thanks to everyone for their advice / suggestions.Maybe use IsAdmin()?.This is my best option.At least i can use it toss up a msg box and advise the user that Admin rights are required to use the function Edited April 28, 2009 by Shark007
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