[英]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.