Forum Discussion

rushikesh's avatar
rushikesh
Contributor
7 years ago

How to kill an application from test complete.

Hi,

 

In my script  I am closing the tested application and relaunching it. 

Sometimes application fails to close and when relaunch code is executed I get error that one or more instance of application is running. 

So is there a way to kill application through test complete ? 

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    .Terminate() method (Sys.Process('YourProcess').Terminate() ).

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      AlexKaras wrote:

      Hi,

       

      .Terminate() method (Sys.Process('YourProcess').Terminate() ).


      In addition to what AlexKaras has given you, I would suggest including in whatever code you're using to close your application under test to do some sort of checking.  Something like

       

      var myApp = Sys.WaitProcess('MyApp', 2000);
      if (myApp.Exists){
          myApp.Terminate();
      }
  • m_essaid's avatar
    m_essaid
    Valued Contributor

    hi,

    I have this little piece of script that waits for a process to be killed :

     

    procedure KillProcess(ProcessName: string);
    var
      p, IsClosed;
    begin
      p := Sys.FindChild('ProcessName', ProcessName);
      while p.Exists do
      begin
        p.Close;
        IsClosed:= p.WaitProperty('Exists', False);
        if not IsClosed then
          p.Terminate;
        p:= Sys.FindChild('ProcessName', ProcessName);      
      end;  
    end;