Forum Discussion

nedbacan's avatar
nedbacan
Frequent Contributor
4 years ago
Solved

Capturing the Command Line of a Process running in the Task Manager

I don't know if this test is possible but I would like to ask the experts if it can be done.

 

Using TestComplete, is there a way to capture the command line of a process that appears in the Task Manager.

 

When a certain task (double click on a link) in the web application is called,  I would like to verify the process for that task has the correct command line and then copy it to the log result.  The process remains visible in the task manager for about 10 seconds before it gets cleared.

 

Is there a Javascript method that will do this without launching the task manager? 

 

 

Thank you !!!

 

 

 

  • One way to do that is using PowerShell

     

    gwmi win32_process | select commandline, name | format-list

     

     I am sure you can massage the data a little better and use a filter to just find "httpd.exe".

  • The simplest way is to use the builtin functions.

     

    let n = "TestComplete";
    let p = Sys.Find("ProcessName", n);
    p.Exists ? Log.Message(p.CommandLine) : Log.Message("Process " + n + " not found !");
    

     

    Or if the process to check is always the same :

    Sys.Process("TestComplete").Exists ? Log.Message(Sys.Process("TestComplete").CommandLine) : Log.Message("Process not found !");
    

     

16 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero

    The simplest way is to use the builtin functions.

     

    let n = "TestComplete";
    let p = Sys.Find("ProcessName", n);
    p.Exists ? Log.Message(p.CommandLine) : Log.Message("Process " + n + " not found !");
    

     

    Or if the process to check is always the same :

    Sys.Process("TestComplete").Exists ? Log.Message(Sys.Process("TestComplete").CommandLine) : Log.Message("Process not found !");
    

     

    • tphillips's avatar
      tphillips
      Frequent Contributor

      Oh wow BenoitB I didn't realise the Process object had those properties like that. That's way better than my answer!

      • BenoitB's avatar
        BenoitB
        Community Hero
        tphillips this is the problem with TC, so rich that everyday you discover something 😜
    • nedbacan's avatar
      nedbacan
      Frequent Contributor

      Hello BenoitB , I appreciate for providing me with the process check sample.  Great !!  

       

      I modified the script to look for the process that needs to be capture but it returns "Process octDataParser not found !' but when I placed back "TestComplete" it returns with the process command line for TestComplete. 

       

      Is there something I am changing wrong or missing to add?

       

      function ProcessFinder()
      {
      let n = "octDataParser_core.exe";
      let p = Sys.Find("ProcessName", n);
      p.Exists ? Log.Message(p.CommandLine) :
      Log.Message("Process " + n + " not found !");
      }

       
       

       

      • BenoitB's avatar
        BenoitB
        Community Hero
        Use the Name property that you see in Object browser, typically it's name without '.exe'
  • tphillips's avatar
    tphillips
    Frequent Contributor

    One way to do that is using PowerShell

     

    gwmi win32_process | select commandline, name | format-list

     

     I am sure you can massage the data a little better and use a filter to just find "httpd.exe".