Create shortcut of UWP app into Startup folder. RRS feed

  • Question

  • Hi

    I need to create my UWP app shortcut into startup folder from my MainPage.cs(on loaded event) page or App.cs (onLunching event) so that next time when I open my machine app start automatically every time. 

    sandeep chauhan

    Wednesday, October 31, 2018 1:37 PM

All replies

  • Hi,

    UWP did not provide such APIs to create a shortcut for one app.  As it turns out, all of the applications installed on your PC—including the universal apps that come with Windows 10 or are downloaded from Windows Store—are accessible from a hidden shell view called Applications. You can open the Run dialog (WINKEY + R), type shell:AppsFolder and then click OK to view this folder, in the folder, you can find all the installed applications.

    There is a workaround for that in UWP. You can use a desktop bridge to execute powershell script to create the shortcut. Here are the detail steps:

    1. Use powershell cmdlet to create shortcut for one app. To prevent your shortcut from having the standard Explorer icon. Change the $Shortcut.TargetPath. And you can also create a shortcut *.url via URI(https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-default-app).The Startup folder is USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. You can run shell:startup to view in explorer.
    ,$TargetPath =  "C:\Windows\explorer.exe"
    $ShortcutFile = $env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\{shortcut name}.lnk"
    $WScriptShell = New-Object -ComObject WScript.Shell
    $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
    $Shortcut.Arguments = "shell:AppsFolder\{app family name}!App"
    $Shortcut.TargetPath = $TargetPath

    1. In UWP, we can’t execute the powershell script.  But we can create a desktop bridge to launcher the script. Here are the steps how to create a bridge.
      1. Add the Windows Desktop Extensions for the UWP in your UWP project.
      2. Declare the windows.FullTrustProcess extension in your appxmanifest.
      3. Declare an app service for communicating between your UWP and the fulltrust process, it is optional.
      4. Include the Win32 EXE which can invoke the powershell in your package that will get launched from the FullTrustProcessLauncher API.

    You can refer this samplehttps://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/JourneyAcrossTheBridge which details the steps to create desktop bridge to UWP.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 1, 2018 8:42 AM