简体   繁体   English

如何将快捷方式固定到NSIS的开始菜单?

[英]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. 我有一个NSIS安装程序脚本,该脚本调用CreateShortcut将条目添加到开始菜单。 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? 我已经看到了一些有关如何执行此操作的VBScript示例 ..那是我对NSIS的唯一选择,还是有更好的方法?

Windows 8 should pin it automatically for you while 8.1 will not . Windows 8应该自动为您固定它, 而8.1不会

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. 使用StdUtils插件的InvokeShellVerb函数可以做到这一点。

This works for Windows 7 and up. 适用于Windows 7及更高版本。

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    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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