How to Hide the "FoxPro Run Command" Window

Last reviewed: September 14, 1995
Article ID: Q131621
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

SUMMARY

By using the FOXTOOLS.FLL library that ships with FoxPro, you can execute an MS-DOS command or program without seeing the "FoxPro Run Command" window or another MS-DOS session. This is done by registering and calling the Windows API WinExec() function as demonstrated in this article.

MORE INFORMATION

The following program creates a sample function that executes an MS-DOS command or program and keeps the MS-DOS window hidden. The program takes one parameter, the command to be executed.

To maintain control over the MS-DOS window, the program sends the command through a PIF file. To keep this window hidden, use the Windows PIF Editor to make the following changes to the PIF file you use (this example uses FOXRUN.PIF in the FoxPro directory):

  1. Select the "Close Window on Exit" check box.

  2. Set "Display Usage" to "Windowed."

Code Sample

*-------------------- RUN.PRG ----------------------- * Sample program to Execute an MS-DOS command and keep * the MS-DOS window hidden. * * To use this function in FoxPro to create a new directory, * use one of the following two commands that illustrate two * ways to call the function and achieve the same result: * * =RUN("MD C:\FPW26\TESTDIR") * * DO RUN WITH "MD C:\FPW26\TESTDIR" *

FUNCTION run PARAMETER doscmd

SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE

winexec = REGFN("WinExec", "CI", "I")

* To have control over the visibility of the * MS-DOS command, call it through a PIF file.

* IMPORTANT: (1) Be sure the "Close Window on Exit" check box in * in the PIF file is selected. (2) Be sure "Windowed" is the * selected "Display Usage."

cmdstart = SYS(2004)+"FOXRUN.PIF /C "

* Now concatenate the 2 pieces of the command:

fullcmd = cmdstart + doscmd

retval = CALLFN(winexec, fullcmd, 0)

RELEASE LIBRARY SYS(2004)+"foxtools.fll"


Additional reference words: 2.60a FoxWin
KBCategory: kbprg kbcode
KBSubcategory: FxprgFoxtools


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 14, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.