locked
RemoteApplication.terminateRunningInstances doesn't work for windows phone 8.1 appx RRS feed

  • Question

  • Hi,

    I want to write a tool to stop an app on windows phone 8.1. Uninstall command works as what I expect. But when I called terminateRunningInstances, it didn't actually stop the appx. When I download storage file from windows phone, it said files are still used by another process, which means that appx is not stopped...

    Why is that? This API works for windows phone 8 xap. It doesn't work for appx?

    Below is the code I use in c#.

    ConnectableDevice connectableDevice = multiTargetingConnectivity.GetConnectableDevice(deviceId);
    IDevice device = connectableDevice.Connect();
    Guid guid = new Guid(cmdLineArgs.CmdArg);
    if (!device.IsApplicationInstalled(guid))
    {
              Console.WriteLine("app is not installed!");
              return;
    }
    Console.WriteLine("Stopping " + guid);
    IRemoteApplication application = device.GetApplication(guid);
    application.TerminateRunningInstances();
    device.Disconnect();

                          


    Wednesday, December 17, 2014 6:28 AM

Answers

  • I will close this question.
    The API is not working for wp8.1 appx.

    Workaround to unblock myself:

    added a timeout mode to the test app to exit when timeout.

    Thursday, December 25, 2014 9:42 AM

All replies

  • It should work, as far as I know, currently, the tools for WIndow phone always use RemoteApplication.terminateRunningInstances to handle this, check http://wptools.codeplex.com/SourceControl/latest

    private void btnKillApp_Click(object sender, RoutedEventArgs e)
    {
                if (CurSelectedInstalledApp != null)
                {
                    CurSelectedInstalledApp.RemoteApplication.TerminateRunningInstances();
                    Analytics.Instance.Track(Analytics.Categories.App, "Kill");
                }
    }


    Best Regards,
    Please remember to mark the replies as answers if they help

    Thursday, December 18, 2014 5:23 AM
  • I have looked at the AppDeployCmd.exe. It indeed used RemoteApplication.TerminateRunningInstances() to kill app before uninstall packages. And I have seen many code samples using that API. But I think most of them may be only consider apps before wp8.1 appx. Wp 8.1 appx is a big change, I think.

    I followed it and tried myself. This API indeed works for wp8.0 xap, and doesn't work for wp8.1 appx. My device is Nokia 909 and Nokia 920.

    Thursday, December 18, 2014 12:51 PM
  • I will close this question.
    The API is not working for wp8.1 appx.

    Workaround to unblock myself:

    added a timeout mode to the test app to exit when timeout.

    Thursday, December 25, 2014 9:42 AM