Forum Discussion

uusarath's avatar
New Contributor
9 years ago

i was not able to run a bat file as administrator from test complete

I was not able to execute  batch file  as administrator.


i was trying to execute the below commands from batch file


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


I tried launching the Test Complete as Administator and nothing worked.


Please help me on this

1 Reply

  • You're on a 64-bit OS and the 'query' command is only available in a 64-bit environment.  A 32-bit CMD shell (which is what you get when you try to run a BAT file or invoke CMD.EXE from 32-bit TestComplete) does not have the query command.


    To get the BAT file to run in a 64-bit environment, you'll have to invoke a 64-bit CMD shell from TestComplete and run the BAT file from that CMD shell.  To do that, use the following on your TestedApps Application and Command-line parameters lines:



    /c <your bat filename here>



    There is a little bit of info here ( Getting System Folder Paths ) and somewhat more here ( PROCESSOR_ARCHITEW6432 ) and elsewhere on the web.