如何关闭从Windows 10 c#wpf Launcher.launchurisync打开的应用程序

如何关闭从Windows 10 c#wpf Launcher.launchurisync打开的应用程序,wpf,windows,Wpf,Windows,我已经创建了一个使用Launcher打开Windows10安装的应用程序的演示 private async void OpenApp() { var launchUri = new Uri("URL of Installed APP"); var success = await Launcher.LaunchUriAsync(launchUri); b1 = success; if

我已经创建了一个使用Launcher打开Windows10安装的应用程序的演示

private async void OpenApp()
        {
            var launchUri = new Uri("URL of Installed APP");

            var success = await Launcher.LaunchUriAsync(launchUri);
            b1 = success;
            if (success)
            {
                // URI launched

            }
            else
            {
                // URI launch failed
            }

        }
例如,我已经从Launcher打开了windows设置应用程序。我想在一段时间后关闭WPF应用程序中的同一个应用程序

可能吗?请告诉我一些解决办法。

简短回答:没有

launchurisync
API只启动与指定URI的URI方案名称关联的默认应用程序,并返回一个指定操作是否成功的
bool
。它不会给你任何类型的引用回到(可能)打开的默认应用程序,因此你无法真正关闭该应用程序。没有API可以做到这一点

在WPF中,您可以通过终止进程来关闭特定的应用程序:


在UWP中,您不允许终止进程,因此无法关闭由
launchurisync
API打开的应用程序。

我找到了解决方案。我搜索包exe并从任务管理器线程关闭它。这将解决我的问题。