Forum Discussion

hina's avatar
hina
Contributor
2 years ago

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

    • hina's avatar
      hina
      Contributor

      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

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Does it work for you if you try just

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

        ?