Windows 10 NSIS 卸载程序也删除通知图标
Windows 10 NSIS uninstaller to also remove notification icon
我正在开发 windows 10 应用程序,但我注意到当我卸载它时,它的图标仍保留在通知和操作中 window。我需要做什么或添加到我的卸载程序以允许它删除此图标。这就是我的 .nsi 脚本中卸载程序的样子
Section "Uninstall"
Call un.XXXXXXXXX
ExecWait '"$INSTDIR\f2p_ping.exe" --f2p' [=11=]
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegKey HKLM "SOFTWARE\MyApp"
DeleteRegKey HKCU "Software\MyApp\Overlay\ExcludedProcesses"
DeleteRegKey HKCR "MyApp"
RMDir /r "$INSTDIR"
RMDir /r $PROGRAMFILES\MyApp
RMDir /r "$APPDATA\MyApp\*.*"
; Remove shortcuts, if any
SetShellVarContext current
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
SetShellVarContext all
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
Delete "$DESKTOP\MyApp.lnk"
; Remove directories used
SetShellVarContext current
RMDir "$SMPROGRAMS\MyApp"
SetShellVarContext all
RMDir "$SMPROGRAMS\MyApp"
RMDir "$INSTDIR"
SectionEnd
最好的解决方案可能是让您的应用程序隐藏通知,因为它已经包含通知代码。 运行 卸载程序开始时类似 ExecWait '"$InstDir\MyApp.exe" /uninstall'
的内容。
可能可以将其中一个 IToast* 接口与系统插件一起使用,但需要大量代码,我不知道 Windows 是否可以让您假装是另一个应用程序,方法是使用它的应用程序模型 ID。例如,关于 IToastNotificationHistory::Remove:
,MSDN 是这样说的
The app ID of the app that sent the specified toast notification. This app must be part of the same app package as the app making this remove request.
MSDN 也有关于桌面应用程序的说法:
Generally, sending a toast notification from a desktop app is the same as sending it from a Windows Store app. However, you should be aware of these differences and requirements:
- For a desktop app to display a toast, the app must have a shortcut on the Start screen.
- The shortcut must have an AppUserModelID.
- Desktop apps cannot schedule a toast.
我正在开发 windows 10 应用程序,但我注意到当我卸载它时,它的图标仍保留在通知和操作中 window。我需要做什么或添加到我的卸载程序以允许它删除此图标。这就是我的 .nsi 脚本中卸载程序的样子
Section "Uninstall"
Call un.XXXXXXXXX
ExecWait '"$INSTDIR\f2p_ping.exe" --f2p' [=11=]
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegKey HKLM "SOFTWARE\MyApp"
DeleteRegKey HKCU "Software\MyApp\Overlay\ExcludedProcesses"
DeleteRegKey HKCR "MyApp"
RMDir /r "$INSTDIR"
RMDir /r $PROGRAMFILES\MyApp
RMDir /r "$APPDATA\MyApp\*.*"
; Remove shortcuts, if any
SetShellVarContext current
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
SetShellVarContext all
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
Delete "$DESKTOP\MyApp.lnk"
; Remove directories used
SetShellVarContext current
RMDir "$SMPROGRAMS\MyApp"
SetShellVarContext all
RMDir "$SMPROGRAMS\MyApp"
RMDir "$INSTDIR"
SectionEnd
最好的解决方案可能是让您的应用程序隐藏通知,因为它已经包含通知代码。 运行 卸载程序开始时类似 ExecWait '"$InstDir\MyApp.exe" /uninstall'
的内容。
可能可以将其中一个 IToast* 接口与系统插件一起使用,但需要大量代码,我不知道 Windows 是否可以让您假装是另一个应用程序,方法是使用它的应用程序模型 ID。例如,关于 IToastNotificationHistory::Remove:
,MSDN 是这样说的The app ID of the app that sent the specified toast notification. This app must be part of the same app package as the app making this remove request.
MSDN 也有关于桌面应用程序的说法:
Generally, sending a toast notification from a desktop app is the same as sending it from a Windows Store app. However, you should be aware of these differences and requirements:
- For a desktop app to display a toast, the app must have a shortcut on the Start screen.
- The shortcut must have an AppUserModelID.
- Desktop apps cannot schedule a toast.