I have an NSIS script that works great, and creates Start menu shortcuts, one of which points to a batch file. The issue is the user will have to right-click and Run as Administrator or it will fail. Is there a way to create the shortcut to Run as Administrator? I am not trying to bypass security, just have it prompt the UAC automatically. The only alternative I could think of is to instruct the user in the batch file, which is tacky IMO. I also thought of searching for Run as Administrator for the batch file itself, but also came up empty.
Here is the Start Menu section of my NSIS installer:
# CREATE SHORTCUTS
!insertmacro MUI_STARTMENU_WRITE_BEGIN MySoftware
# Create shortcut.
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\$SMGroup"
CreateDirectory "$SMPROGRAMS\$SMGroup\Uninstaller"
SetOutPath $SMPROGRAMS\$SMGroup
CreateShortCut "$SMPROGRAMS\$SMGroup\GO.lnk" "$INSTDIR\bin\go.bat"
CreateShortcut "$SMPROGRAMS\$SMGroup\Uninstaller\Uninstall.lnk" $INSTDIR\Uninstaller.exe
SectionGetFlags ${SEC_SCHEDULER} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} svc jump1 jump1
svc:
# Create shortcut to Scheduler Service Manager
CreateShortCut "$SMPROGRAMS\$SMGroup\Scheduler.lnk" "$INSTDIR\bin\${SVC_MGR_BAT}"
jump1:
DetailPrint "Registry Entry: ${REGKEY}\StartMenu : $SMGroup"
WriteRegStr HKLM "${REGKEY}" StartMenu $SMGroup
!insertmacro MUI_STARTMENU_WRITE_END
Edit: I have checked the CreateShortCut reference, and see no mention of it, but thought there might be some workaround elsewhere in the NSIS script. CreateShortCut NSIS
There is a feature request for this here but it has various issues so it has not been implemented:
If you still believe this is a good idea you can use this or this...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With