![]() |
#1 |
Junior Member
Join Date: May 2010
Posts: 19
|
CreateShortcut to run as administrator
Good day.
I need to create shortcut with advanced property "Run as administrator" set. Help needed. |
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
|
![]() |
![]() |
![]() |
#3 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
Well, it is possible, but a pain to write in a script.
Maybe a plugin is easier: http://social.msdn.microsoft.com/For...9-2e3df3668989 |
![]() |
![]() |
![]() |
#4 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
You can also try to add a REG_SZ key named <Full_Path _To_My_Application.exe> with a value of "RUNASADMIN" to the registry at HKCU\SOFTWARE\Microsoft\Windows_NT\CurrentVersion\AppCompatFlags\Layers.
(Source: http://www.techtalkz.com/windows-dep...all-users.html) I don't have Vista, so I can't test this for you. |
![]() |
![]() |
![]() |
#5 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
One could update this plug-in (it would probably have to be me though):
http://nsis.sourceforge.net/ShellLink_plug-in Stu |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,337
|
People keep asking this over and over, but it seems to me that you probably have other problems if you need this property set on your shortcuts (What if the user runs the app directly?) Anyways, here is some code: http://nsis.sourceforge.net/IShellLink_Set_RunAs_flag
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#7 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
I've updated the ShellLink plug-in but currently the Wiki is down.
Stu |
![]() |
![]() |
![]() |
#8 |
Junior Member
Join Date: May 2010
Posts: 19
|
MSG Elevating application is not the decision I need. Simple users should have the ability to run it.
Anders, I understand, that writing programs that require administrative rights is not good. But my program is meant for system administrators. There will be two shortcuts - for simple users with restricted possibilities - and for admins, full functioning. Thank you, Afrow UK, it works fine. Thanks for you all a lot. There are several topics on this issue on the forum. But only here is the helpful solution. |
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Oct 2005
Posts: 19
|
Hello Afrow UK!
Many thanks for your great solution. This works fine for my application. Because of the many threads about this problem perhaps it could become part of the next NSIS setup. |
![]() |
![]() |
![]() |
#10 |
Junior Member
Join Date: May 2010
Posts: 19
|
I have a problem - I set flag "Run as Administrator" using this code: http://nsis.sourceforge.net/IShellLink_Set_RunAs_flag
If my shortcut is placed in All users Start menu, then it works great. But in Start menu of current user - no flag is set. |
![]() |
![]() |
![]() |
#11 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Is the path correct? (SetShellVarContext).
Stu |
![]() |
![]() |
![]() |
#12 |
Junior Member
Join Date: May 2010
Posts: 19
|
Yes, path is correct. The code is:
CreateShortcut "$SMPROGRAMS\wtc\${wtcTxt}-Administrator.lnk" "$INSTDIR\Bin\win32.exe" push "$SMPROGRAMS\wtc\${wtcTxt}-Administrator.lnk" call ShellLinkSetRunAs pop $0 As far as I understood this function returned not 0: System::Call "$2->5(w '$9',i 0)i.r0" ;Load |
![]() |
![]() |
![]() |
#13 |
Junior Member
Join Date: May 2010
Posts: 19
|
Afrow UK, you were right.
"Windows Vista and Windows 7 automatically identifies installer executables, including NSIS installers, and asks the user permission to run them with elevated privileges. Automatic detection, however, comes with the price of automatic backward compatibility tricks. One of which is automatic relocation of shortcuts created in the Start Menu to All Users' Start Menu." I hate Microsoft ![]() |
![]() |
![]() |
![]() |
#14 |
Junior Member
Join Date: May 2010
Posts: 19
|
Afrow UK, you were right.
"Windows Vista and Windows 7 automatically identifies installer executables, including NSIS installers, and asks the user permission to run them with elevated privileges. Automatic detection, however, comes with the price of automatic backward compatibility tricks. One of which is automatic relocation of shortcuts created in the Start Menu to All Users' Start Menu." I hate Microsoft ![]() |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|