Forum Discussion

DKNP's avatar
DKNP
Occasional Contributor
8 years ago

Running a batch file via Tested apps not working as expected

Hi

 

I am running a batch file that should disconnect me from the Virtual machine, however, when i run the batch file via tested apps i get a syntax error in the batch file.

 

The content is

 

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
  %windir%\System32\tscon.exe %%s /dest:console
)

 

The error is 'query' is not a recognized as an internal or external command, operable program or batch file.

 

When I run the batch file manually it works as intended. Also Testcomplete is running in administrator mode.

 

Any ideas?

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    How do you have the batch file being called in TestComplete?  My suggestion would be to run it using CMD.EXE /c to actually shell out to execute the batch if you're not already doing so.

  • Ravik's avatar
    Ravik
    Super Contributor

    try like this- 

     

    Set shell = CreateObject("WScript.Shell")
    shell.Run "cmd /k myBatch.bat", 1, True