Partager via


RUN | ! Command

Executes external operating commands or programs.

RUN [/N] MS-DOSCommand | ProgramName

-or-

! [/N] MS-DOSCommand | ProgramName

Parameters

  • MS-DOSCommand
    Specifies the MS-DOS command to execute. See your MS-DOS documentation for more information about available MS-DOS commands.
  • ProgramName
    Specifies the program or application to run. You can specify a Windows-based or an MS-DOS-based program or application.
  • /N
    Specifies NOWAIT. Include the letter N to execute another Windows-based application.

Remarks

You can issue RUN from within the Command window or from within a program.

Note   To use RUN, you must have the operating system file Command.com in the current directory, or it must be located where the MS-DOS COMSPEC parameter can find it. For more information on COMSPEC, see your MS-DOS documentation.

Caution   Do not use RUN to run disk reorganization programs such as CHKDSK from within Visual FoxPro. These programs modify the contents of your disk in a manner that may prevent Visual FoxPro from operating properly.

RUN and Visual FoxPro   When RUN is used to run programs outside of Visual FoxPro, it searches for programs in a slightly different manner from FoxPro for MS-DOS.

If the program you specify in RUN doesn't have an extension, Visual FoxPro first look along the MS-DOS path for a Program Information File (PIF) with the name you specify. A PIF lets you run other programs under Windows. You can specify parameters for the program, whether the program is run in a window or on the full screen, the amount of memory allocated for the program, and so on.

If the PIF is found, the program specified in the PIF is executed with the PIF parameters. If a PIF isn't found, the MS-DOS path is then searched for an executable file with the name you specify.

When a PIF isn't found, Visual FoxPro uses FOXRUN.PIF, a PIF installed in the Visual FoxPro directory. FOXRUN.PIF is configured to run the program in a window. You can modify FOXRUN.PIF to run programs in another configuration.

Windows 2000 logo Certification If you plan to submit your application for certification, you should not use the RUN command, because it can potentially violate the following System Group Policy requirement.

"RUN only allowed Windows application - your application must not start any application that is not on this list. Note this does not apply when launching applications through COM. If you use ShellExecuteEx, Windows 2000 will perform this check automatically."

Instead, you should use DECLARE DLL with ShellExecuteEx.API.

FOXRUN.PIF   Foxrun.pif allows you to execute MS-DOS® and Windows® programs and commands from within Visual FoxPro. Foxrun.pif must be in the same directory as Vfp8.exe in Visual FoxPro.

/N means NOWAIT. Include the letter N to execute another Windows-based application. For example, the following statement opens the Windows Character Map accessory:

! /N CHARMAP.EXE 

The following example opens the Windows color picker from the Windows Control Panel:

! /N CONTROL COLOR

A Windows-based application executed with RUN /N or ! /N behaves the same way the application does when you open it through the Windows Explorer or by selecting Run from the Start menu. You can switch between the application and Visual FoxPro or FoxPro for Windows using the standard Windows operations.

You can include an optional numeric value immediately after /N to specify how the Windows-based application is opened. Do not include any spaces between /N and the numeric value. The following table lists the numeric value you can include and describes the state of the Windows-based application when opened.

Value Application attributes
1 Active and normal size
2 Active and minimized
3 Active and maximized
4 Inactive and normal size
7 Inactive and minimized

Running MS-DOS Programs in Visual FoxPro   By default, Foxrun.pif runs the specified external MS-DOS program in a window. While the MS-DOS program or command is running, the title of the window is FoxPro Run Command. In Visual FoxPro, the FoxPro Run Command window is closed after the external program or command is finished executing.

You can use the Windows PIF editor to customize Foxrun.pif. You can edit the PIF to specify if the Inactive FoxPro Run Command window is left open or is closed (the default in Visual FoxPro) with the Close Window on Exit check box. You can also open external programs in a full screen by selecting Full Screen; allocate memory for the program; and so on.

Memory Considerations   By default, Foxrun.pif allocates a minimum of 256K of memory for running an external command or program. If you do not have 256K of free conventional memory, Visual FoxPro displays an error message. To correct this, try one or both of the following:

  • Close applications and files to free up additional memory.
  • Edit Foxrun.pif to reduce the amount of memory required in the KB Required text box.

If the external command requires more than 256K, MS-DOS displays an error message in the FoxPro Run Command window. To correct this, edit your Foxrun.pif to increase the amount of memory required in the KB Required text box.

See Also

GETENV( ) | _SHELL System Variable