Solved

launch a program and send enter key

Posted on 2001-06-22
21
562 Views
Last Modified: 2011-04-14
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--


thanks

0
Comment
Question by:patrickm3
  • 4
  • 4
  • 3
  • +7
21 Comments
 
LVL 11

Expert Comment

by:griessh
ID: 6219286
The echo command has a nice feature:
"echo." will just send out a CR

echo. | program.exe

should work.

Good luck

======
Werner
0
 

Author Comment

by:patrickm3
ID: 6219334
I'm not sure I understand

what is a CR?
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 6219363
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

echo.|yourProg.exe

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.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6219409
Thanks for the clarification, sometimes we just expect everybody knows tech-talk :-)

======
Werner
0
 

Author Comment

by:patrickm3
ID: 6219466
I'm not sure I understand

what is a CR?
0
 

Author Comment

by:patrickm3
ID: 6219893
doesn't seem to work--

when is the cr sent??

I need it sent after the program is launched
0
 
LVL 11

Expert Comment

by:griessh
ID: 6220038
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

======
Werner
0
 

Author Comment

by:patrickm3
ID: 6220086
I need the enter key to be pressed on a windows program that setp.exe launches--is that the pronlem???
0
 
LVL 11

Expert Comment

by:griessh
ID: 6220105
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.

Sorry

======
Werner
0
 
LVL 7

Accepted Solution

by:
rin1010 earned 100 total points
ID: 6221062

patrick,

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:        r.com 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:    r.com 00:00:10 "" r
...or you could shorten it to:    r.com 0:0:10 "" r

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

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

To remove it from memory, use:    r.com -

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:
r.com 0:10:10 "" r >nul

To test it at a command prompt, make it send Enter in 3 seconds, like:    r.com 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
setup.exe/q
R.COM -

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 r.com 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:

http://users.aol.com/pasacaca/enterrun/r.com

 
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

by:andydis
ID: 6230346
if your using windows try the at command.

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

at

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)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 6238414
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.

Richard.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6239871
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)
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6247726
Create some file (for example called 'yes'). Enter one empty line and save it.
Then start your program with
'program.exe < yes'
0
 

Expert Comment

by:ComTech
ID: 6382694
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
details.

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.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



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.

ComTech
Community Support Moderator @ Experts Exchange
0
 
LVL 10

Expert Comment

by:Longbow
ID: 6391655
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
http://www.experts-exchange.com/jsp/qShow.jsp?ta=win95&qid=20168176

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

Longbow

0
 

Expert Comment

by:ComTech
ID: 6392868
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.

Regards,
ComTech
Community Support

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

Expert Comment

by:Longbow
ID: 6392951
Ok Comtech,

I am waiting...

Longbow
0
 
LVL 7

Expert Comment

by:rin1010
ID: 6395240

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.
 
0
 
LVL 10

Expert Comment

by:Longbow
ID: 6396186
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.

Longbow

0
 

Expert Comment

by:ComTech
ID: 6420472
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.

ComTech
Community Support
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now