0

I have created a demo which opens Windows 10 installed APP using Launcher.

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
            }

        }

For Example I have opened the windows settings application from Launcher. I want to close the same application from my WPF application after some interval of time.

Is it possible? Please let me know some solutions.

Anil P
  • 163
  • 1
  • 2
  • 16

1 Answers1

1

Short answer: No.

The LaunchUriAsync API just starts the default app associated with the URI scheme name for the specified URI and returns a bool that specifies whether the operation was successful. It doesn't give you any kind of reference back to the default app that was (maybe) opened so you cannot really close the app. There is no API to do this.

In WPF, you might be able to close a specific app by terminating the process: Kill some processes by .exe file name

In UWP you are not allowed to kill a process though so then there is no way to close the app opened by the LaunchUriAsync API.

mm8
  • 163,881
  • 10
  • 57
  • 88
  • I have found the solution. I search the package exe and close it from task manager thread. this will solve my problem. – Anil P Feb 07 '18 at 05:52