PDA

View Full Version : Setting shortcut to run as Admin


hobbes487
14th November 2010, 17:09
I have search the forum and read all the thread relating to this topic, but cant seem to get it to work. Here is the code I am using:


createShortCut "$SMPROGRAMS\OSA\Manager.lnk" "$INSTDIR\OSAE Manager.exe"

ShellLink::SetRunAsAdministrator "$SMPROGRAMS\OSA\Manager.lnk"

The shortcut is created, but it is not set to run as administrator. I am testing on Windows 7. Do I need to use the UAC plugin?

Anders
14th November 2010, 18:06
Can you do a MessageBox with "$SMPROGRAMS\OSA\Manager.lnk" and make sure the path is correct, if it is not, you have issues with UAC/SetShellVarContext, if it is correct, the problem is with ShellLink::SetRunAsAdministrator

hobbes487
14th November 2010, 23:16
It looks like the path is not correct. what do I need to do to make sure it is pointing to the shortcut?

Anders
15th November 2010, 12:49
Make sure the SetShellVarContext mode is the same before the calls to CreateShortcut and ShellLink::SetRunAsAdministrator