设置UWP程序自启动(Automate launching Windows 10 UWP apps)
在开发UWP程序的过程中,有时候需要设置程序的自启。本人实现的步骤如下:
1.在VS中激活Protocol
(Package.appxmanifest --> Declarations --> Add Protocol),图示如下:

2.编译并发布项目(Build and Deploy)
发布之后Protocol被激活,在(控制面板 --> 程序 --> 默认程序 --> 设置关联)中可以找到MYAPPLICATION的关联。

3.命令行启动UWP程序
打开命令行提示符,我们可以使用URI来启动,示例如下:
>start myapplication: //不带参数
>start myapplication:test-parameter //带参数
输入上述命令即可启动应用。
4.程序中添加重写方法
在上述步骤完成后,虽然可以启动UWP应用程序,但是程序中要重写OnActivated方法来导航到需要显示的页面。
在App.xaml.cs中重写OnActivated方法。
protected override void OnActivated(IActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
} var protoclForResultsArgs = (ProtocolActivatedEventArgs)args;
rootFrame.Navigate(typeof(MainPage), protoclForResultsArgs);
Window.Current.Activate();
}
5.使用Windows服务在命令行启动程序
命令行实现URI程序启动后,可以编写Windows服务程序来监听某些条件,从而启动UWP程序。需要注意的点如下:
(1).System.Diagnostics.Process可以实现程序中执行cmd命令;
(2).Windows服务启动UWP程序,需要在ProjectInstaller中设置serviceProcessInstaller的Account属性为User,并指定相应的用户;
(3).如何创建Windows服务的链接:
https://msdn.microsoft.com/zh-cn/library/zt39148a(v=vs.110).aspx#BK_CreateProject
设置UWP程序自启动(Automate launching Windows 10 UWP apps)的更多相关文章
- Mobilize.Net Silverlight bridge to Windows 10 UWP
Windows UWP 既 Windows 10 Universal Windows platform,这个微软基于Windows NT内核的个运行时(Runtime)平台,此平台横跨所有的 Wind ...
- DevExpress Windows 10 UWP Controls新版亮点
行业领先的.NET界面控件2018年第二次重大更新——DevExpress v18.2日前正式发布,本站将以连载的形式为大家介绍新版本新功能.本文将介绍了DevExpress Windows 10 U ...
- Windows 10 UWP开发:如何去掉ListView默认的选中效果
原文:Windows 10 UWP开发:如何去掉ListView默认的选中效果 开发UWP的时候,很多人会碰到一个问题,就是ListView在被数据绑定之后经常有个默认选中的效果,就像这样: 而且它不 ...
- DevExpress v18.1新版亮点——Windows 10 UWP篇
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress Windows 10 UWP v18.1 的新功能,快来下载 ...
- 修改 Windows 10 UWP 应用任务栏图标
修改 Windows 10 UWP 应用任务栏图标 Windows 7 时代,修改任务栏图标很简单,右键打开属性,更改图标即可.但步入 Windows 8 之后,随着应用商店 UWP 应用的问世,可以 ...
- SQLite.Net-PCLUSING SQLITE IN WINDOWS 10 UNIVERSAL APPS
USING SQLITE IN WINDOWS 10 UNIVERSAL APPS 1.下载SQLite VSIX package并安装 http://sqlite.org/download.html ...
- Windows 10 UWP程序标题栏设置
在Windows 10程序中,以前只能用于全屏方式的Metro程序现在可以运行在窗口模式下了,并且改了个新名字,叫Windows 通用程序(Universal Windows app),简称UWP程序 ...
- 自动启动 Windows 10 UWP 应用
原文: https://docs.microsoft.com/zh-cn/windows/uwp/xbox-apps/automate-launching-uwp-apps 简介 开发人员有多种选项可 ...
- 面向初学者的 Windows 10 UWP 应用开发
眼看 Windows 10 for Mobile 正式版也快要推送了,就先挖个坑吧,原文视频链接为:Windows 10 development for absolute beginners,以下博客 ...
随机推荐
- js 中的流程控制-循环(for)语句
for语句: <script> /* for(exp1;exp2;exp3){ 循环体; } exp1:无条件的执行第一个表达式 exp2:判断是否能执行循环体的条伯 exp3:做增量的操 ...
- php多行字符串输出
$content_header =<<<CONTENT_HEADER <section class="content-header"> <h ...
- CI源码引用使用--php引用demo,静态变量和引用关系
CI源码引用使用在Common.php中,加载配置和类的方法 function &test() { static $a = ''; if (!$a) { $a ...
- alter system register
alter system register的用法 1 Static Registration via set the listener.ora2 Dynamic Instance Registrati ...
- js中对象调用对象中的方法
var o = {a:"abc", b:{ c:function(param){ alert(this.a); //这里的this指向的不是o而是b,所以this是没有a属性的,这 ...
- scrollView and tableView
As we all know, tableView is the subclass of scrollView, tableView has every properties that scroll ...
- winform下载网页源码
public partial class Form1 : Form{public Form1(){InitializeComponent();} private void button1_Click( ...
- SSL交互和握手过程
SSL消息按如下顺序发送: 1.Client Hello 客户发送服务器信息,包括它所支持的密码组.密码组中有密码算法和钥匙大小: 2.Server Hello 服务器选择客户和服务器都支持的密 ...
- 转:阿里开源Mysql分布式中间件:Cobar
原文来自于:http://hualong.iteye.com/blog/2102798 这几天研究了下Cobar, Cobar是阿里巴巴研发的关系型数据的分布式处理系统(Amoeba的升级版,该产品成 ...
- 0x1L
整形常量的后缀表示其类型,包括如下后缀,其中U和L的大小写通用 后缀 类型L long int LL long long int U ...