NSIS 脚本中是否有 InvokeShellVerb 的替代方案?

Is there any alternative of InvokeShellVerb in NSIS Script?

我想在 windows 中将快捷方式固定到任务栏 10. 脚本工作正常,但我的实用程序被检测为恶意木马。微软已经删除了这个动词,这可能是相同的原因。那么有没有其他方法可以以编程方式 pin/unpin 任何程序。

    OutFile "C:\PinUnpinExe\PinUnpinShortcut.exe"

!include 'StdUtils.nsh'
!include FileFunc.nsh

SilentInstall silent
RequestExecutionLevel user ;no elevation needed
ShowInstDetails hide

var inputParam
Section
    ${GetParameters} $inputParam
    System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
    ${StdUtils.InvokeShellVerb} [=10=] "[=10=]" "abc.exe" $inputParam
SectionEnd

此行被检测为病毒。

 ${StdUtils.InvokeShellVerb} [=11=] "[=11=]" "abc.exe" $inputParam

我也接受其他语言的解决方案。

Don't programmatically pin shortcuts, the taskbar is a place for users放上自己喜欢的图标!

要取消固定,您可以这样做 (NSIS 3+):

!include "LogicLib.nsh"
!include "Win\COM.nsh"

!macro UnpinShortcut lnkpath
Push [=10=]
Push 
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 ""
${If} [=10=] P<> 0
    System::Call 'SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' "${lnkpath}"
    ${If}  P<> 0
        ${IStartMenuPinnedList::RemoveFromList} [=10=] '(r1)'
        ${IUnknown::Release}  ""
    ${EndIf}
    ${IUnknown::Release} [=10=] ""
${EndIf}
Pop 
Pop [=10=]
!macroend

Section Uninstall
!insertmacro UnpinShortcut "$SMPrograms\MyApp.lnk"
SectionEnd