Page 1 of 1

Wait for input

Posted: 29 Oct 2021 15:21
by drgt
I want to start an external program (program.exe) and enter parameters at the time of batch execution.
I do not mean [batch_filename_Space_Parameter...]

Code: Select all

Prompt>program [blinking cursor]
Doable?

Re: Wait for input

Posted: 30 Oct 2021 00:04
by Gerhard
That will depend on the executable, does it allow for input at runtime? cmd cannot interact with the executable, so it will simply launch it when you tell it to. Obviously if the program allows parameters, you should be able to run it as program.exe param1 param2 and in some use cases if it accepts stdin you can echo answers and pipe to the executable. echo Y|program.exe. Other than that, cmd cannot interact with executables.

Wait for input

Posted: 30 Oct 2021 00:28
by drgt
I am not sure if I was clear enough...
When executing the batch file, I want to show the system prompt with the program name pretyped, space and wait with blinking cursor for me to type parameters and hit enter before the batch resumes and launch the program.

If that is what you understood, thank you for the answer!

Re: Wait for input

Posted: 30 Oct 2021 00:32
by Gerhard
you mean like this?

Code: Select all

@echo off
set /p "runme=Program.exe"
"program.exe" "%runme%"

Wait for input

Posted: 30 Oct 2021 01:24
by drgt

Code: Select all

@echo off
set /p "runme=program.exe "
start program.exe %runme%
exit
EXACTLY!
Thank you!

Re: Wait for input

Posted: 30 Oct 2021 01:33
by Gerhard
No problem. If you're going to use start, rather do it the correct way as well using the blank title:

Code: Select all

start "" program.exe "%runme%"

Wait for input

Posted: 30 Oct 2021 01:36
by drgt
ok. !

You must omit "" from "%runme%"

Re: Wait for input

Posted: 30 Oct 2021 04:53
by aGerman
Depends on your input in the SET /P command. Don't forget to enclose parameters into quotes that contain spaces or other special characters. However, I think what Gerhard tried to point out is that you should always consider to use the empty pair of quotes after START because START treats the first quoted parameter as window title. That's why

Code: Select all

start program.exe
works while

Code: Select all

start "C:\path whith spaces\program.exe"
doesn't work.

However

Code: Select all

start "" program.exe
works, and so does

Code: Select all

start "" "C:\path whith spaces\program.exe"
Steffen