【发布时间】:2014-08-12 02:12:20
【问题描述】:
我有一个 NSIS 安装程序脚本,它调用 CreateShortcut 向开始菜单添加一个条目。但是,我想在新创建的快捷方式中将选项设置为“固定到开始菜单”。
这可能吗?我已经看到一些VBScript examples 告诉我如何做到这一点。这是我在 NSIS 的唯一选择,还是有更好的方法?
【问题讨论】:
我有一个 NSIS 安装程序脚本,它调用 CreateShortcut 向开始菜单添加一个条目。但是,我想在新创建的快捷方式中将选项设置为“固定到开始菜单”。
这可能吗?我已经看到一些VBScript examples 告诉我如何做到这一点。这是我在 NSIS 的唯一选择,还是有更好的方法?
【问题讨论】:
Windows 8 会自动为您固定 while 8.1 will not。
虽然可以模拟固定快捷方式,但您是not really supposed to do it。
如果你想变得邪恶而不遵循指导方针,你可以使用this plugin...
【讨论】:
这可以使用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
【讨论】: