Wait for input

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Wait for input

#1 Post by drgt » 29 Oct 2021 15:21

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?

Gerhard
Posts: 11
Joined: 25 Oct 2021 22:01

Re: Wait for input

#2 Post by Gerhard » 30 Oct 2021 00:04

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.

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Wait for input

#3 Post by drgt » 30 Oct 2021 00:28

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!

Gerhard
Posts: 11
Joined: 25 Oct 2021 22:01

Re: Wait for input

#4 Post by Gerhard » 30 Oct 2021 00:32

you mean like this?

Code: Select all

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

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Wait for input

#5 Post by drgt » 30 Oct 2021 01:24

Code: Select all

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

Gerhard
Posts: 11
Joined: 25 Oct 2021 22:01

Re: Wait for input

#6 Post by Gerhard » 30 Oct 2021 01:33

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%"

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Wait for input

#7 Post by drgt » 30 Oct 2021 01:36

ok. !

You must omit "" from "%runme%"

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Wait for input

#8 Post by aGerman » 30 Oct 2021 04:53

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

Post Reply