简体   繁体   中英

How to pin shortcut to start menu with NSIS?

I've got an NSIS installer script which calls CreateShortcut to add an entry to the start menu. However, I would like to set the option to "Pin to Start Menu" in that newly created shortcut.

Is this possible? I've seen some VBScript examples on how to do this.. is that my only option with NSIS, or is there a better way?

Windows 8 should pin it automatically for you while 8.1 will not .

While it is possible to simulate pinning a shortcut you are not really supposed to do it .

If you want to be evil and not follow the guidelines you can use this plugin ...

This is possible using the InvokeShellVerb function of the StdUtils plugin.

This works for Windows 7 and up.

Here's an example preserved here for posterity...

!include 'StdUtils.nsh'

RequestExecutionLevel user ;no elevation needed for this test
ShowInstDetails show

Section
    IfFileExists "$SYSDIR\mspaint.exe" +3
    MessageBox MB_ICONSTOP 'File does not exist:$\n"$SYSDIR\mspaint.exe"$\n$\nExample cannot run!'
    Quit
SectionEnd

Section
    DetailPrint "Going to pin MSPaint..."
    ${StdUtils.InvokeShellVerb} $0 "$SYSDIR" "mspaint.exe" ${StdUtils.Const.ShellVerb.PinToTaskbar}
    DetailPrint "Result: $0"

    StrCmp "$0" "ok" 0 +3
    MessageBox MB_TOPMOST "Paint should have been pinned to Taskbar now!"
    Goto +2
    MessageBox MB_TOPMOST "Failed to pin, see log for details!"
SectionEnd

Section
    DetailPrint "Going to un-pin MSPaint..."
    ${StdUtils.InvokeShellVerb} $0 "$SYSDIR" "mspaint.exe" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
    DetailPrint "Result: $0"

    StrCmp "$0" "ok" 0 +3
    MessageBox MB_TOPMOST "Paint should have been un-pinned from Taskbar now!"
    Goto +2
    MessageBox MB_TOPMOST "Failed to un-pin, see log for details!"
SectionEnd    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM