Bodman Posted April 26, 2012 Share Posted April 26, 2012 I have written a script and used the code Func Print() #RequireAdmin Run(@COMSPEC & " /c RunDll32 shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder") EndFunc as one of the functions. But I only want the Admin to be required when the function is called and not when I run the script as this affects other parts of my script. Is this possible....any ideas ? Bodman Link to comment Share on other sites More sharing options...
Mat Posted April 26, 2012 Share Posted April 26, 2012 Try something like this: AutoIt Project Listing Link to comment Share on other sites More sharing options...
KaFu Posted April 26, 2012 Share Posted April 26, 2012 This might work: ShellExecute("RunDll32.exe","shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder","","runas") OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Bodman Posted April 26, 2012 Author Share Posted April 26, 2012 (edited) Thanks Both, im sorry my example of my code above was bad. Ill try to explain what im doing.I want to open the startup folder for the logged on user but run the script as a adminSo I want to runRun("explorer.exe " & @StartupDir)and this opens the folderC:UsersLOCALUSERNAMEAppDataRoamingMicrosoftWindowsStart MenuProgramsStartupbut when UAC kicks in and I enter the admin details. It doesnt open this folder.In A Ideal world the UAC wouldnt kick in until the func is called. Edited April 26, 2012 by Bodman Link to comment Share on other sites More sharing options...
KaFu Posted April 26, 2012 Share Posted April 26, 2012 Well, well, seems like another case of "it does not work by design", here's some interesting reading on why Win7 blocks calls to elevate explorer.exe (including some dirty registry hacking).http://social.technet.microsoft.com/Forums/en-US/w7itprosecurity/thread/1798a1a7-bd2e-4e42-8e98-0bc715e7f641Don't know if it works (currently I'm on XP with no Win7 at hand), but just give it a try. On XP it works when I disable the "Protect my computer..." checkbox in the elevation prompt:ShellExecute("iexplore.exe", "file:" & @StartupDir, "", "runas") OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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