Forum Discussion

krkarthik_info's avatar
krkarthik_info
Frequent Contributor
5 years ago
Solved

How to capture the powershell result on calling the external application(.exe with arguments)

Hi All,

 

I am trying to run powershell command through TestComplete, command to call the external application(.exe) with argument. And the command returns the message to the powershell console.

 

Unable to read the message displayed in the powershell console through TestComplete.

 

Below is the format of the command am using to exec through TestComplete:

 

var PowerShellObj = Sys.OleObject("WScript.Shell");
var Command = "C:\cmd_tool.exe --list-data";
  
var oExec = PowerShellObj.Exec("powershell -command "+Command );

Note:

Manually when I run the same command in powershell console, I could see the message displayed on the console.

 

Thanks in advance.

 

Thanks,

Karthik K R

 

  • Hi Robert,

     

    Thanks for the suggestion.

     

    I have got the problem resolved. I was using the StdOut.ReadAll() to get the console output.

     

    Thanks,

    Karthik K R

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You've already stated the key problem... you can see it on the console.  so, you would need to write code in TestComplete to scrape the screen of the console to grab the information.  Alternatively, you could have Powershell output the information to a file that can then be read by TestComplete.  But that's really the key... you need to code TestComplete to find the information.

    • krkarthik_info's avatar
      krkarthik_info
      Frequent Contributor

      Hi Robert,

       

      Thanks for the suggestion.

       

      I have got the problem resolved. I was using the StdOut.ReadAll() to get the console output.

       

      Thanks,

      Karthik K R