Jump to content



Photo

#requireadmin and UAC problems


  • Please log in to reply
4 replies to this topic

#1 Bodman

Bodman

    Seeker

  • Active Members
  • 49 posts

Posted 26 April 2012 - 08:55 AM

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





#2 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,042 posts

Posted 26 April 2012 - 08:58 AM

Try something like this:

http://www.autoitscript.com/forum/topic/124368-uac-elevate-and-deelevate-scripts/

I don't know where I'm going, but I'm on my way.


#3 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,165 posts

Posted 26 April 2012 - 09:07 AM

This might work:

ShellExecute("RunDll32.exe","shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder","","runas")


#4 Bodman

Bodman

    Seeker

  • Active Members
  • 49 posts

Posted 26 April 2012 - 09:35 AM

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, 26 April 2012 - 09:35 AM.


#5 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,165 posts

Posted 26 April 2012 - 10:41 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users