How can I create a desktop shortcut for a Windows 10 Universal app using powershell?

后端 未结 4 1187
情话喂你
情话喂你 2021-01-14 14:21

I have a UWP app I created and want to use powershell to create a shortcut on the desktop.

Creating a shortcut is easy for an exe

$TargetFile =  \"\\         


        
4条回答
  •  感情败类
    2021-01-14 15:17

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

    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()
    

    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.

提交回复
热议问题