[英]How to pin shortcut to start menu with NSIS?
我有一个NSIS安装程序脚本,该脚本调用CreateShortcut
将条目添加到开始菜单。 但是,我想在新创建的快捷方式中将选项设置为“固定到开始菜单”。
这可能吗? 我已经看到了一些有关如何执行此操作的VBScript示例 ..那是我对NSIS的唯一选择,还是有更好的方法?
使用StdUtils
插件的InvokeShellVerb
函数可以做到这一点。
适用于Windows 7及更高版本。
这是为后代保留的示例 ...
!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.