0

I am writing a short batch file, that I will run from the command window, that goes through all the subfolders that start with a sequence ("01" in my case) and runs a .exe file located in each folder.

@echo off
CD "C:\Users\Acuna\Desktop\simulations"
for /D /r %%d in ("01*") do (
  pushd "%%d"
  start "" /wait hydro_2dm.exe
  popd
)

The problem I am having is that when I run the .exe file (which runs well with the code) in the last line it asks me to press enter to continue and exit the process, and I have not been able to emulate this from a batch file. I search in several forums and they recommend this line when calling the .exe

echo yes | call hydro_2dm.exe

but it didn't work. Does anyone have a suggestion on how to solve that problem?

Thank you in advance!

eacuna
  • 1
  • 1
  • 2
    is hydro a GUI? if not, perhaps you can show me a screenshot of the prompt where it requests to press enter. Remember that not all applications will accept input from stdin. if however it is a GUI, you won't get any results using `cmd` as it does not interact with programs. – Gerhard Oct 13 '21 at 08:14
  • Hi Gerhard, I mananed to solved the problem using echo & echo.| call hydro_2dm.exe. Thank you for the input! – eacuna Oct 14 '21 at 12:06

1 Answers1

0

Yep, just use this:

@if (@a==@b) @end /*

:: batch portion


:loop
cls
@ECHO OFF
cscript /e:jscript "%~f0"
:: JScript portion */
var shl = new ActiveXObject("WScript.Shell");

var shl = new ActiveXObject("WScript.Shell");
for (var i=0; i<50; i++) {
    shl.SendKeys(String.fromCharCode(0x0D));

}
    

goto :loop

This script just spams the "enter key" Go here https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes?redirectedfrom=MSDN for more info. It may be a good solution, but you can set a delay with the command "timeout" by simply inserting it here if needed:


:: batch portion


:loop
timeout 1
cls
@ECHO OFF
cscript /e:jscript "%~f0"
:: JScript portion */
var shl = new ActiveXObject("WScript.Shell");
    shl.SendKeys(String.fromCharCode(0x0D));


goto :loop

In this case, just change the number after timeout command just after the loop for the amount of seconds you would like.

ouflak
  • 2,458
  • 10
  • 44
  • 49
f41e
  • 1
  • 1