cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Frequent Contributor

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Contributor

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

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 2
Community Hero

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

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Frequent Contributor

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

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

New Here?
Join us and watch the welcome video:
Join the September Hub-bub to show off, learn and win