launch a program and send enter key

I need to launch a program overnight that requires the enter key to be pressed one time --

I think this can be done easily in dos, can anyone help???

lets say I need to run c:\update.exe  and when it runs I need to have the enter key pressed--


Who is Participating?


I have a couple of programs that will run a command at a given time or at a specified interval.
If you've tried griessh's method and verified your syntax is correct and it still doesn't work
on your application, you may need to use a tsr to send your program a command
and be able to do it under both DOS or Windows.

If you need something for Windows only, I can help with some VB source to get your app
to do it or to alleviate user intervention. But if you simply want the system to "press"
the Enter key at some point after your program launches, I have a small utility
that should do it for you in DOS mode or Windows.

You mentioned that you're launching a program "overnight"... I'm not exactly clear
as to how your launching your setup.exe but i presume ultimately from a batch file?
I have a tsr utility that can be scheduled to run an app and then also send the Enter key,
but if there's already a way of running it or the batch file, then this other one may be enough.

This utility can be loaded in memory and then send the Enter key after
a specified number of hours, minutes and/or seconds. The tsr can be loaded at any time,
but i suppose in this case you'd want to run it immediately before your program
and have it send Enter within a few seconds (or whenever is necessary.)
It can also be removed from memory when you're done with it,
although it doesn't use much. I'll place it where you can get it if you want to give it a try.

The syntax to load it and have it send the Enter key is like this: hh:mm:ss "" r

The program's name is R.COM but you can change that and can change the extension to
.exe if needed. The two quotation marks followed by a space and the letter R are necessary
to instruct it to send the Enter key. (The R can be upper or lower case.)
The values used in the "time" portion determine how long before Enter is sent.
The format can be  hh:mm:ss  or  h:m:s  or mixed variations, but a number must be provided
for all three values (hours, minutes, seconds) and separated by a colon.
To remove the program from memory, type its name followed by a space and a minus sign.
Some examples:

To send Enter in 10 seconds use: 00:00:10 "" r
...or you could shorten it to: 0:0:10 "" r

To send Enter in 10 minutes and 10 seconds use: 00:10:10 "" r
...or you could do it like: 0:10:10 "" R

To send Enter in 14 hours and 11 seconds you could use: 14:00:11 "" r
...or just do it like:    R 14:0:11 "" R

To remove it from memory, use: -

There are prompts if you get the syntax wrong, but be sure to use the
two quotation marks and the trailing R ...
You can also suppress the screen output by piping its commands to the nul device, like: 0:10:10 "" r >nul

To test it at a command prompt, make it send Enter in 3 seconds, like: 0:0:3 "" r
Wait 3 seconds and you'll see it send the Enter key (or carriage return - line feed character.)
You'd just need to experiment a little to figure out the appropriate time for it
to send Enter to your program. Then if you want to try it in a batch file
you could do something similar to:

@echo off
R.COM 00:00:10 "" R

That would load it and set it to send Enter in 10 seconds, then launch your program and
subsequently remove itself from memory. (Include the file paths as necessary.)

Anyway, if to want to try this utility, download the file below...
I got it down fairly small, approx. 5k... If it works for you and you have questions about it,
please ask... Otherwise post back and maybe we can find another method...
Here's the url:

The echo command has a nice feature:
"echo." will just send out a CR

echo. | program.exe

should work.

Good luck

patrickm3Author Commented:
I'm not sure I understand

what is a CR?
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

CR - "Carriage Return" - which is what you get when you press the enter key.

so like griessh says just put echo.| in front of the command that starts your program. This is done in a batch file. You create a batchfile (somefile.BAT) and type the command


into it and save the batch file. Then you can launch the batch file and it will run your program, and it will simulate hitting the enter key for you.
Thanks for the clarification, sometimes we just expect everybody knows tech-talk :-)

patrickm3Author Commented:
I'm not sure I understand

what is a CR?
patrickm3Author Commented:
doesn't seem to work--

when is the cr sent??

I need it sent after the program is launched
The CR is sent to the program and when it waits for input, it will get it.
What type of program is it? (MSDOS program, Windows Program)

The . must be right after the "echo" -> "echo."
The "|" is the 'pipe' character on your keyboard, the funny vertical line.

Try this:
run "pause" from a command window. It will wait for a key to be pressed.
now run "echo. | pause" and you will see the text, but the program continues.
If your program is a "wellbehaved" software it should do the same thing ...
Let me know

patrickm3Author Commented:
I need the enter key to be pressed on a windows program that setp.exe launches--is that the pronlem???
Oh, sure! You have to create an Event for Windows. That's adiffernt animal. Since you posted in the MSDOS section, I didn't expect that.
We will see if somebody comes up with a mixed solution for DOS/Windows. I am sure it is possible, but a bit out of my reach right now.


if your using windows try the at command.

for example open a dos windows ( start> run>command)
and type


if it says unrecogized bacth or program name then it wont work but if it dsoes say something then you can set a time when u wanna kick off your program...

(avaliable on NT/2k)
Richard QuadlingSenior Software DeveloperCommented:
The easiest way is to get hold of the recorder from windows v3.1x

You could then schedule the recorder to load the program and then press the enter key.

1) Another goodie but oldie is use of Key-Fake, to stuff input buffer with keystrokes

2) Every command, Windows or not, should have its own version of /s, run in silent mode, or noninteractive mode. To find out what such options might be available, try running your program from Win's start/run and append a /? for helpful information (such as how to go silent). If that is not effective, try ambiguous or illegal command, such as running program with no parameters at all, or with characters as options that should be invalid, to force an error message that may describe the options.

3) Try using left angle bracket for input file full of command line options, ex:
program     <   CR

Where CR is file. Put what you want there, perhaps simply creating it from command line, edit, press <enter> key, then save as filename of CR or whatever is descriptive for it.

4) to launch overnite, I prefer WinAT scheduler (windows version of AT command), available from resource kit or web download. But for NT it ought to be available as new commandline option. Nice about WinAT is a window that can display status remotely, while permitting quick changes to scheduler. Do not run alternative schedulers (they break things)
Create some file (for example called 'yes'). Enter one empty line and save it.
Then start your program with
'program.exe < yes'
It's time to clean up this topic area and that means taking care of this question. Your options at this
point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on
the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To
use this option, you must state why the question is no longer useful to you, and the experts need to
let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you
must state why the question is no longer useful to you, and the experts need to let me know if they
feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.
 We also request that you review any other open questions you might have and update/close them.  Display
all your question history from your Member Profile to view details.



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which
Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest
that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one
week to finalize this question.

Thank you everyone.

Community Support Moderator @ Experts Exchange
Hi ComTech,

Questioner is not answering :-( and we don't know the solutions will help.

I have another solution to help and i may set an answer instead of a comment without doubt. It works perfectly.
This question is like this found at

I propose to delete the question.
Or give me the points ;-)


Longbow, be patient for another few days, and I'll be back to clean what is over due here.  Part of the purpose of leaveing the reminder to return to the question.  As you have seen, that does not always work.  I have about a 40% return rate on the older questions.

Community Support

Ps. no nee to lock it, when I return to finish these, I will take a comprehensive look at all supplied comments.
Ok Comtech,

I am waiting...


Hi Longbow... You mention having a solution that "works perfectly."
Note that a DOS and Windows solution was mentioned but may not be required.
I created and provided a utility that will work and do it in either Windows or DOS mode
and offered to provide some vb source if that would be considered an option.
Please provide your code if you think it will work and that the user can maintain the script
and hopefully Patrick will have successfully tried some of these things and report back.
Hi Rin1010,

If Patrick have answered i agree with you.
You will find the code in the url i provide above.
I just test it in a dos window and it works.

Have a nice day.


Hi Longbow, I have looked at your comment in the lind you provide, but rin1010 has already proposed a solution that now only works for Dos, but I tried it in WinMe, Windows NT and Windows 98se, and it is also what I use to long onto my Cable Network at home. (I'll try it later tonight with my WindowsXP Pro RC1 Beta ver.)

griessh had the first correct answer if the User wanted it to work only in Dos.  But I will now accept the first bi-soulution and move to PAQ.

Thanks all, great job.

Community Support
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.