Solved

Sending Inputs to DOS Apps.

Posted on 1998-08-25
5
178 Views
Last Modified: 2010-04-30
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?
0
Comment
Question by:nbishop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:raygibbins
ID: 1431003
Try something like this

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

0
 

Author Comment

by:nbishop
ID: 1431004
raygibbins.  Your solution seems to work well for Windows applications, but I really need a sendkeys function for a DOS window.
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 170 total points
ID: 1431005
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
 

Author Comment

by:nbishop
ID: 1431006
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
 

Expert Comment

by:cameron2
ID: 1431007
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

734 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