Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simulating Enter key in .bat

Status
Not open for further replies.

Cretin

Technical User
Jan 2, 2003
194
0
0
US
We have some .exe files that reside on a windows box. We would like to automate them. There is one problem, they need input parameters. my task is to write DOS programs to do it. Now before you tell me that there are other scripts we should do that with i agree and suggested that to the powers that be, unfortunately DOS is what they told me to use.

I define some variables as such:
set FIELD1=Y
set FIELD2=N
set FIELD3=N
echo.| set FIELD4
echo. |set FIELD5

This is how I pass the parameters. Fields 1-3 are pretty straight forward. However fields 4 and 5 need to press the enter key to continue running the .EXE. The echo. | before the set is the latest thing I saw by googling. When I google I come up with many ways to do this none of which worked all the way from it can't be done and to get some software package (technical services at my company says no) to the echo . | Any ideas would be welcome.

Cretin
 
If the only entry in FIELD4 and FIELD 5 is to be a Carriage Return, then you can try:

set FIELD4=chr(13)



HTH,
Bob [morning]
 
Tried that got the following message

chr(13) was unexpected at this time

Cretin
 
Cretin,

Didn't seem like it should be so difficult ...

And you may not like it - I surely don't.

But the cost is free ...

I wonder if you weren't given this task as a test or challenge.

1. Create a text file using a hex editor. I used HxD. If you need one, it's at:

2. Use the hex editor to make the contents of the file hex 0D.
Save this file somewhere that is accessible to anyone needed the Enter (Carriage Return) in a batch file.

3. Add the following to your batch file to load a variable. I don't know how it works, but it seems to.

For this example, the text file is named CR.txt and the variable to load is FIELD4

FOR /F "tokens=1 delims=" %%A in ('CR.txt') do SET FIELD4=%%A echo %myVar%


If you try this, please advise if it works.


HTH,
Bob [morning]
 
Not sure about being tested I have written numerous .bat's. I have just never encountered one that needs a press enter to continue. When I put your code in it just opens the hex file it does not load the enter to the variable. I will keep working on it.

Cretin
 
Ok thanks I do have a few ideas left I will let you know

Cretin
 
I just couldn't completely give up.

Try this:

set /a FIELD4=\x0D

Also, check to see if there are options available with programs requiring Enter. I.E., I have used some that had parameter options for automated use. Something like:

C:\path\someprog.exe /a

where the /a indicated to the program it was being run in automatic mode, like within a batch file.


HTH,
Bob [morning]
 
I think the issue is I am trying to feed an executable the enter code. I am wondering if I need to simulate the enter code in the language of the .exe. I don't know what that is it was externally written.

Cretin
 
It's possible that feeding the enter code via parameter happens too quickly.

I.E., the parameter is read immediately upon program load rather than when the program is looking for it.

Usually, there are speedy replies here ...

Maybe the pro's are chuckling to themselves while we're trying to sort it out.

Good Luck!
Bob


HTH,
Bob [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top