Sending Inputs to DOS Apps.

Basically, I want to run a DOS executable in a "BATCH" mode.
The original design of the DOS app did NOT take into accout command line arguments, or script files.  SO, what I would like to do is programatically send inputs to a running DOS window (Or any other way possible to run the program repeatedly, and unattended).  Is this possible?
nbishopAsked:
Who is Participating?
 
mark2150Connect With a Mentor Commented:
You have to fall back on that old DOS standard, input redirection.

Assuming that your program accepts input from STDIN then you can create a short ASCII text file with the commands in it. Then when you fire the program put:

SHELL( "program < ASCII.TXT", 1)

This will cause the program to accept input from the ASCII file as if it were typed from the keyboard.

FYI you can also capture the program's output by using:

> RESULT.TXT

The sad part of this is that the connections are *NOT* dynamic. Your ASCII.TXT file plays like a macro, no parameter substitution and on interpretation. Thus if your DOS program bumps into an error or some other unexpected condition it'll go south. You also can't read the RESULT.TXT file to find out what is happening until after the DOS program has exited.

0
 
raygibbinsCommented:
Try something like this

Dim ret As Long
ret = Shell("Path and Batch Filename", vbNormalFocus)
SendKeys "{RIGHT}", True

0
 
nbishopAuthor Commented:
raygibbins.  Your solution seems to work well for Windows applications, but I really need a sendkeys function for a DOS window.
0
 
nbishopAuthor Commented:
Not exactly what I was hoping to hear, but I think I can work with that.  I have read about an API call to the function sendMessage, but haven't really been successful. Any ideas about that?
0
 
cameron2Commented:
Make a new project and then add a new commandbutton. Type in this code in your commandbutton. I have tryed this on windows programs and it works But I don’t see why it wont work in dos.  

Sub Command1_Click()
   
MyApp shell("C:\Example.exe", 1) 'You put in your own          
                                 'Program here

AppActivate MyApp                'Runs the program Example.exe  

   'Send the string and hit enter to the current
   'window in "C:\Example.exe"
   SendKeys "This is a simple test{ENTER}"
End Sub
0
All Courses

From novice to tech pro — start learning today.