Set up UWP program self-boot (automate launching Windows ten UWP apps)

Source: Internet
Author: User

Original: Set up UWP program self-boot (automate launching Windows UWP apps)

In the process of developing a UWP program, it is sometimes necessary to set the program's self-start. The steps I implemented are as follows:

1. Activating protocol in VS

(Package.appxmanifest---Declarations and Add Protocol), as shown below:


2. Compiling and publishing the project (Build and Deploy)

Protocol is activated after publishing, and the association of MyApplication can be found in (Control Panel------The default program---set association).

3. Command line launch UWP program

To open a command-line prompt, we can start with a URI, with the following example:

>start MyApplication:                   //without parameters >start Myapplication:test-parameter     //with parameters

Enter the above command to launch the app.

4. Add an override method to the program

After the above steps are complete, you can start the UWP application, but you will override the Onactivated method in your program to navigate to the page you want to display.

Override the Onactivated method in App.xaml.cs.

 protected  override  void   OnActivated (Iactivatedeventargs args) {Frame rootframe 
    = Window.Current.Content as   Frame;  if  (rootframe = = null  " {Rootframe  = new   Fram        E ();    Window.Current.Content  = Rootframe;  var  protoclforresultsargs = (    Protocolactivatedeventargs) args; Rootframe.navigate ( typeof   (MainPage),    Protoclforresultsargs);          Window.Current.Activate (); }

5. Using Windows services to start a program at the command line

After the command-line implementation URI program starts, you can write a Windows service program to listen for certain conditions to start the UWP program. The points to note are as follows:

(1). System.Diagnostics.Process can implement the cmd command in the program;

(2). The Windows service launches the UWP program and needs to set the account property of ServiceProcessInstaller to user in ProjectInstaller and specify the appropriate users;

(3). How to create a link to a Windows service:

https://msdn.microsoft.com/zh-cn/library/zt39148a (v=vs.110). Aspx#bk_createproject

Set up UWP program self-boot (automate launching Windows ten UWP apps)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.