Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Returning to DOS

Posted on 1999-07-14
Medium Priority
Last Modified: 2010-05-02
I have a VB program that I am calling from within a DOS program.  When I exit the Visual Basic Program I want the control to return to the calling program i.e the DOS program.  Any ideas on how to do this....
Question by:I_jolly
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
LVL 12

Expert Comment

ID: 1524651
Use a batch file. The VB .EXE file will spawn and run and the batch will resume control immediately. If you need to synchronize the activity have the batch file create a marker file that is deleted during the VB program's shutdown.

ECHO This is the marker file > MARKER
... execution resumes when VB program deletes MARKER file...



Author Comment

ID: 1524652
Hi Mark 2150,

That’s a good answer..........But.....The focus is returned to the DOS calling program in a minimised state i.e simply highlighted on the toolbar.  I want control to return to the calling program in the state that the control program called it i.e Maximised screen.

I have increased the points as I know it’s not an easy one.

Thanks Iain

LVL 12

Expert Comment

ID: 1524653
The state is restored to how the DOS window was when the VB.EXE was launched. If you were maximized to begin with, you'll resume maximized.


Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1524654
Hi Mark,
I have tried this several times now but with no joy.  I might be doing something wrong...I have created a VB.exe file that on closing deletes a file c:\test.txt.
I have created the batch file below.
From a DOS command prompt I run the batch file.  The VB exe is spawned.  When I close the VB program focus is returned to the DOS command on my task bar - I am still in windows and to see the DOS batch running I have to click on the task bar.  Thanks for all the help though.  If I'm doing something wrong then let me know.  I'll leave the question up for a week and if I can't get exactly what I'm looking for I'll give you the points.

Cheers Iain.

IF EXIST c:\test.txt GOTO HOLD
echo hello
goto control
LVL 12

Expert Comment

ID: 1524655
Open your DOS window to full screen <Alt Enter>. THEN run the batch and see what happens. If you're starting your DOS session from an ICON, check the icon properties and set Run Full Screen.



Expert Comment

ID: 1524656
Another way to do this from a batch file (and to skip the file exists stuff)

in the batch file you only need to have this

start /w c:\Project1.exe

The batch file will wait for the exe to end before continuing on.  No need to create / delete a file between processes.

I think, as has been suggested, to make sure that the settings for your batch file includes the Run Full Screen option.

LVL 10

Expert Comment

ID: 1524657
use CreateProcess() to start that app of yours... use WaitForSingleObject() and wait until your app is done calculating or whatever... then use TerminateProcess() and/or CloseHandle() to close your process (DOS app...)

If you need some sample code please let me know :)

Good Luck!!


Author Comment

ID: 1524658
A good answer but I think Mark2150 pointed me in the correct direction so I will give him the points......If I knew how to that is.
LVL 12

Accepted Solution

mark2150 earned 270 total points
ID: 1524659
Simple enough. Just grade this answer!




Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 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