且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[UWP] [XAML]如何通过Windows服务启动UWP应用程序?

更新时间:2022-10-21 10:24:03


嗨sandeep chauhan,



无法通过调用.exe文件启动UWP应用程序。如果您想要启动UWP应用程序,请使用协议。您可以将协议扩展添加到UWP应用程序,
处理App.xaml.cs中的激活事件。   然后调用Windows RT API

Windows.System.Launcher.LaunchUriAsync(uri)
启动UWP应用程序。



您可以参考此链接获取有关通过URL启动UWP应用程序的更多信息:

处理URI激活





***的问候,



Roy

HI

I created a windows service from where I open an UWP app, its working fine when I running through code. But when I install it and started service through cmd prompt, Service is started and code is also running(checked by write something into a txt file) but my UWP app doesn't open.

Here is the code -

  Process process = new Process()
                {
                    StartInfo = new ProcessStartInfo(@"panasonicdigitalsignage:")
                    {
                        WindowStyle = ProcessWindowStyle.Maximized,
                        WorkingDirectory = Path.GetDirectoryName(@"panasonicdigitalsignage:")
                    }
                };

                process.Start();

Any limitation in UWP for same ?


sandeep chauhan

Hi sandeep chauhan,

UWP app could not be launched by calling .exe file. If you want to launch a UWP app, please use Protocol. You could to add Protocol extension to the UWP app and handle the activated event in the App.xaml.cs.  Then call Windows RT API Windows.System.Launcher.LaunchUriAsync(uri) to launch UWP app.

You could refer this link for more information about launch UWP app via URL: Handle URI activation

Best regards,

Roy