我有一个我创建的 UWP 应用程序,并想使用 powershell 在桌面上创建一个快捷方式。
为 exe 创建快捷方式很容易
$TargetFile = "\Path\To\MyProgram.exe"
$ShortcutFile = "$env:USERPROFILE\Desktop\MyShortcut.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()
但是我正在努力使用什么作为通用应用程序的目标。我也知道我可以轻松地手动创建应用程序的快捷方式,但为此,它需要使用 PowerShell 来完成。有什么想法吗?
最佳答案
为 UWP 应用创建快捷方式与经典桌面不同。可以引用我的另一个回答Where linked UWP tile?
要使用 powershell 在桌面上创建 UWP 应用程序的快捷方式,您可以使用如下代码:
$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 的代码中。
关于powershell - 如何使用 powershell 为 Windows 10 通用应用程序创建桌面快捷方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38359492/