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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop RUN command from displaying DOS window

Status
Not open for further replies.

diesel6460

Programmer
May 31, 2013
9
US
Hello,
Is there a way to stop the RUN command from flashing a DOS window across the VFP screen (the DOS process does not require any user interaction) or alternatively, if I use ShellExecute, how do I make the calling VFP program wait until the ShellExecute operation has completed?
 
To answer your first question, put [tt]/N[/tt] in the command. For example:

[tt]RUN /N "MyProg"[/tt]

But when you do that, VFP won't wait for the DOS program to finish or to exit. Control will return immediately to VFP.

Re ShellExecute(), there is no way for VFP to know whether it is still running or has finished executing, so control always returns to VFP immediately after the ShellExecute().

Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
However, there is another way of achieving your goal:

Code:
oWSH = CREATEOBJECT("wscript.shell")
oWSH.Run("MyProg", 3, .T.)

The "3" means to run the target program maximised. The .T. will tell VFP to wait until the program closes or exits.

Keep in mind that you will need to pass the full path and filename of the target program, unless it is in the Windows path (which is not the VFP path).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
Thanks very much for your suggestion. I implemented the CREATEOBJECT code and it worked perfectly.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top