且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 powershell 为 Windows 10 通用应用程序创建桌面快捷方式?

更新时间:2021-09-23 03:29:35

为 UWP 应用创建快捷方式与经典桌面不同.你可以参考我的另一个回答Wherelinked UWP tile?

Creating shortcut for UWP app is a different story from classic desktop. You can refer to my another answer Where linked UWP tile?

要使用 powershell 在桌面上创建 UWP 应用的快捷方式,您可以使用如下代码:

To create a shortcut of an UWP app on the desktop using powershell, you can for example code like this:

$TargetFile =  "C:\Windows\explorer.exe"
$ShortcutFile = "$env:USERPROFILE\Desktop\MyShortcut.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.Arguments="shell:AppsFolder\Microsoft.SDKSamples.AdventureWorks.CS_8wekyb3d8bbwe!App"
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()

您可以使用@TessellatingHeckler 提供的链接中的方法找到 AppUserModelId,并将代码中的 Microsoft.SDKSamples.AdventureWorks.CS_8wekyb3d8bbwe!App 替换为您想要的 AppUserModelId.

You can find the AppUserModelId using the method in the link provided by @TessellatingHeckler, and replace the Microsoft.SDKSamples.AdventureWorks.CS_8wekyb3d8bbwe!App in the code with your desired AppUserModelId.