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

无AUMID时用PowerShell将便携App固定到Server2022任务栏与开始菜单

在Windows Server 2022中用PowerShell固定便携应用快捷方式到任务栏和开始菜单(无AUMID)

由于目标应用是便携版且无AUMID,无法直接使用官方推荐的内置命令,我们可以通过Windows Shell COM对象实现快捷方式的固定操作。

1. 固定到任务栏

实现逻辑

通过Shell.Application命名空间定位应用程序所在目录,找到目标.exe对应的Shell项,执行"固定到任务栏"的操作命令。

PowerShell脚本

# 替换为你的便携应用.exe完整路径
$appExePath = "C:\Path\To\Your\App.exe"

# 拆分目录与文件名
$appDir = Split-Path -Path $appExePath -Parent
$appName = Split-Path -Path $appExePath -Leaf

# 初始化Shell对象
$shell = New-Object -ComObject Shell.Application
$folder = $shell.Namespace($appDir)
$item = $folder.ParseName($appName)

# 执行固定操作
$item.InvokeVerb("taskbarpin")

# 释放COM对象避免内存泄漏
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($shell) | Out-Null

2. 固定到开始菜单(钉住)

实现逻辑

针对已添加到开始菜单的快捷方式,通过Shell对象定位该.lnk文件,执行"固定到开始屏幕"的操作命令。

PowerShell脚本

# 替换为开始菜单中应用快捷方式的完整路径(.lnk文件)
$startMenuShortcutPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\YourApp.lnk"

# 拆分目录与快捷方式文件名
$shortcutDir = Split-Path -Path $startMenuShortcutPath -Parent
$shortcutName = Split-Path -Path $startMenuShortcutPath -Leaf

# 初始化Shell对象
$shell = New-Object -ComObject Shell.Application
$folder = $shell.Namespace($shortcutDir)
$item = $folder.ParseName($shortcutName)

# 执行固定操作
$item.InvokeVerb("pintostartscreen")

# 释放COM对象
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($shell) | Out-Null

注意事项

  • 脚本需以管理员权限运行,否则可能因权限不足无法修改系统配置。
  • 若taskbarpin或pintostartscreen无效,可尝试区分大小写的命令:TaskBarPin、PinToStartScreen。
  • 执行后系统可能需要几秒时间刷新任务栏与开始菜单显示。

内容的提问来源于stack exchange,提问作者Michel Sommer

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 10:59:59