Send commands to a Batch with user input

Asked

Viewed 297 times

4

Context:
I have a Batch I can’t change, its function is to list some files in a specific directory, and after it lists the files it is waiting for some user command.

Problem:
I would like to automate this process, but without touching the original batch, IE, send that commando that the batch is waiting for via another 1-minute loop batch.

Looking in some forums, I found some people suggesting the use of pipe to send commands, but it doesn’t work at the time the batch waits for user input.

I wonder if anyone has any idea of sending the command at the time the batch waits for input?

Exemplo do batch:    
Arquivos parados em Download    
Não há arquivos parados em Download

COMANDO :
  • 'Cause you don’t create a bat that does all this ?

  • Why can’t you modify the batch that awaits user input? My idea is more or less like this the first batch sees a file every 30 seconds to see if there is the user’s yes or no response and that file is changed by the second batch. Then in 30 seconds the first batch will have a response.

1 answer

0

Probably this bat has a command like that:

set /p comando=Comando:

This waits for something to be typed. If this command has been loaded, you cannot jump later. In that case you would have to have a GOTO sending the script to another field but this must be typed inside the bat.

Ex:

goto Pular
set /p comando=Comando:
:Pular

then the command "set /p command=Command:" would be ignored

also has to send information to the bat when executing it. but the bat would load it as %1 %2 %3... ex:

call teste.bat Fala1 Fala2 Fala3

Test.bat file: (if it goes wrong, remove the "~" sign before the number).

set aa=%~1
set bb=%~2
set cc=%~3
Echo %aa% %bb% %cc%
pause >nul

Browser other questions tagged

You are not signed in. Login or sign up in order to post.