You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell远程推送Toast通知两类问题求解

PowerShell远程推送Toast通知问题解决方案

问题1:BurntToast通过PowerShell Universal远程推送时图片无法显示

原因

远程执行时脚本运行在服务账户上下文,要么没有图片文件的读取权限,要么用了本地相对路径导致远程会话无法解析。

解决方案

  • 用绝对路径存储图片,比如放在C:\ProgramData\ToastImages\这类公共文件夹,同时确保PowerShell Universal的运行账户(比如Local System)对该路径有读取权限。
  • 推送Toast时明确指定图片绝对路径,示例代码:
New-BurntToastNotification -Text "远程通知测试" -AppLogo "C:\ProgramData\ToastImages\logo.png"
  • 如果用网络共享图片,要给服务账户配置共享访问权限,别用需要手动验证的路径。

问题2:UI.Notifications推送Toast后点击非按钮区域触发管理员权限弹窗

原因

点击非按钮区域时,Toast默认启动关联程序,如果脚本是以管理员权限运行的,激活程序会继承高权限,触发UAC弹窗。

解决方案

  • 修改Toast XML的激活类型为protocol,指定无需管理员权限的目标,比如打开默认浏览器:
<toast activationType="protocol" launch="http://localhost">
  <visual>
    <binding template="ToastGeneric">
      <text>通知标题</text>
      <text>点击非按钮区域将打开浏览器</text>
    </binding>
  </visual>
</toast>
  • 尽量用普通用户权限运行PowerShell Universal脚本,避免管理员身份执行。如果必须用管理员权限,在XML里指定不需要权限的可执行文件,比如记事本:
<toast activationType="launch" launch="C:\Windows\System32\notepad.exe">
  <!-- 其他Toast内容 -->
</toast>
  • 把所有交互都放到按钮上,避免非按钮区域的激活,示例XML:
<toast>
  <visual>
    <binding template="ToastGeneric">
      <text>通知标题</text>
      <text>请通过按钮操作</text>
      <image src="C:\ProgramData\ToastImages\logo.png" placement="appLogoOverride"/>
    </binding>
  </visual>
  <actions>
    <action content="查看详情" activationType="protocol" launch="http://localhost"/>
    <action content="关闭" activationType="system" arguments="dismiss"/>
  </actions>
</toast>

内容的提问来源于stack exchange,提问作者Andrew Draper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 13:20:10