Link to home
Start Free TrialLog in
Avatar of MaxwellTurner
MaxwellTurnerFlag for Canada

asked on

Close a DOS program automatically

I've seen that this question has been asked by others but I can't seem to get any of the comments to those questions to work in my situation.  I know little about VB, but I really need to find a way to get my DOS program closed.

At night I run macros in my DOS database(Q&A version 4.0 DOS).  I do this simply by opening the program via windows task scheduler and with the correct command line suffix, the macros run and then the program closes - the macros end on the program's main menu and the keystroke to close the program from here is "X".  

My problem is that only one copy of the program can be open at once, so if someone forgets to close it at the end of the day (which tends to happen alot), the macros will not run - it will try but then abort and give a message that the program is already open.

What I need is a small exe file that I can open with my task scheduler just before my macros are set to run to check if the program is open and close it if it is.  The command line is C:\QA4\QA.COM.

As I mentioned I don't know VB very well, but I have worked with ACCESS a fair bit.  I have Visual Basic 6.0 from what I can tell, it looks similar to ACCESS in that I would need to create a form with some code attached to it, then compile it into a exe file??  Could someone confirm this process?  I'm pretty sure that with some help with the code and a general idea as to how to create a VB prject I will be on my way.

Thanks in advance

Max
Avatar of aeklund
aeklund

1) Can you write your macros in a batch file, and after the last macro use the command "exit" to exit.

2) Or you can try to write a VB program to shell out the macros, e.g. Shell "C:\QA4\QA.COM"
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MaxwellTurner

ASKER

Aeklund - I have no problems closing the program after the macro's have run, the problem is making sure that it is closed boefore the macros run.

Vinnyd79 - I'm not sure what you mean by the window caption.  The program usually is run outside of windows.  I use Win98, but when I open the program, there is no window or caption.

Max
Does the Program show up on the taskbar when it is open?If so,use the caption on the Taskbar.
Beatiful! It works . . well almost. I get a message box that opens up saying that windows cannot shut down this program automatically and it recommends that I use the program's exit command (which is keystroke "X" from the programs main menu).  There is however a choice YES or NO to shut the program down - when I choose YES, it closes.

Any way to handle this message box to select YES.

Another quick question:  I created a form in VB 6.0 and added a command button and attached the code you wrote to it.  I made it into an exe file, but I still have to click the button - how can execute the code when the form opens, and also have the form close after its done.

Max
Vinnyd79,

Well I still have the issue of the windows message popping up and saying it can't close the program automatically.  I have found a few others on EE that have had a similar problem, but couldn't find an solution.

Points to you for providing the code.  I'll ask a new question about the windows message an see if anyone can help.

Max