Sign in to follow this  
Followers 0
Bodman

#requireadmin and UAC problems

5 posts in this topic

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

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#4 ·  Posted (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 admin

So I want to run

Run("explorer.exe " & @StartupDir)

and this opens the folder

C:UsersLOCALUSERNAMEAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup

but 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 by Bodman

Share this post


Link to post
Share on other sites

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-0bc715e7f641

Don'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")

Share this post


Link to post
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
Sign in to follow this  
Followers 0