Ask a Question

How to Execute command line utilities within a testcomplete script

hina
Contributor

How to Execute command line utilities within a testcomplete script

I found the script below from TestComplete forums to execute the command line utilities from TestComplete script:

 

function test()
{
Sys.OleObject("WScript.Shell").Run("C:\\Windows\\system32\\cmd.exe");

var ProcessCmd = Sys.Process("cmd");

var WdwCmd = ProcessCmd.Window("ConsoleWindowClass","*");

WdwCmd.Keys("dir [Enter]");

aqUtils.Delay(5000);

WdwCmd.Close(3000);
}

 

But when I execute this script I get an error: "The window 'C:\Windows\system32\cmd.exe' is invisible and thus cannot be activated". I am not sure what's wrong with the code. I am trying to execute command line utilities within TestComplete script. Any help would be appreciated.

 

Thanks,

Hina

 

 

3 REPLIES 3
AlexKaras
Community Hero

Hi,

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/wshshell/index.html

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Hi Alex,

 

Thank you for the reply. So I want to execute the following commands in Command line in the following sequence:

 

cd\

cd Elink\Deployment

AXISComponents.exe 1

 

On command line it successfully launch the .exe file.

I created equivalent powershell script, as below:

 

Set-Location -Path C:\ELink\Deployment
& "AXISComponents.exe" 1

 

And saved it into the file C:\ELink\Silent Install\DeploymentFolder.ps1

 

Now I wrote TestComplete script to execute this powershell script, as below:

 

function test6()
{
WshShell.Run("powershell -file C:\\ELink\\Silent Install\\DeploymentFolder.ps1");
}

 

but the above script is not launching the .exe file. The problem is that it's hard to trace what's the cause because TestComplete is not even reporting any errors. Can you please let me know what I am doing wrong.

 

Thanks,

Hina

Hi,

 

Does it work for you if you try just

WshShell.Run("C:\\ELink\\Deployment\\AXISComponents.exe");

?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: