Forum Discussion

ramaraja's avatar
ramaraja
New Contributor
6 years ago

How to Terminate Two or more instance of Application

 

I have teste my wpf application using testcomplete. if already two instance of application are opened means how to i terminate that all application and i need to continue sequence of other cases to be run..

 

Note: i already tried TestedApps.<<app>>.Terminate();(when 2 instance of tested application are in open) but it vain.

 

 

Kindly advise me.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    If your application process name in Windows is myApp, then try the following:

     

    function closeApplicationInstances(){
        var currentProcess = Sys.WaitProcess('myApp', 2000);
        while (currentProcess.Exists){
            currentProcess.Terminate()
            currentProcess = Sys.WaitProcess('myApp', 2000);
        }
    }
    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      I wouldn't bother checking for 2 instances.  At the top of your code, before you start the actual test, use tristaanogre's code and close everything, then open your one instance for testing.