LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

system

system

int system (const char command[]);

Purpose

Starts running a program and waits for it to exit. The executable can be an MS-DOS or Windows executable, including *.exe, *.com, *.bat, and *.pif files.

This function does not return until the command terminates. User keyboard and mouse events are ignored until the command exits. Callbacks for asynchronous events, such as idle events, Windows messages, and VXI interrupts, PostDeferred calls, and DAQ events can be called while the command is executing.

Note Note  If you do not want to wait for the program to exit, use LaunchExecutable in the Utility Library.

.exe, .com, and .bat DOS programs use the settings in _default.pif in the Windows directory when running. You can change settings such as priority and display options by editing _default.pif or by creating another .pif file. For more information about creating and editing .pif files, refer to www.msdn.com.

If you need to execute a command built into cmd.exe, such as copy or dir, you can call system with the following command:

cmd.exe /c command args

where command is the command you want to execute. For example, the following function call copies file.tmp from the temp directory to the tmp directory:

system ("cmd.exe /c copy c:\temp\file.tmp c:\tmp");

For more information about cmd.exe, refer to www.msdn.com.

Parameters

Input
Name Type Description
command const char [] Pathname of executable file to run.

If the program is not in one of the directories specified in the PATH environment variable, you must specify the full path. The path can include arguments to pass to the program.

If the program is a .pif, .bat, or .com file, you must include the extension in the pathname. For example, under Windows, the following function call launches the Edit program with the file file.dat:

system ("edit.com c:\file.dat");

Return Value

Name Type Description
status int Contains the returned status of the function. If the argument is a null pointer, the function returns a nonzero value if a command processor is available. If the argument is not a null pointer, the function returns zero if the program was successfully started; otherwise, the function returns one of the following error codes:
Code Description
-1 System was out of memory, executable file was corrupt, or relocations were invalid.
-2 A DLL required by the executable cannot not be found.
-3 File was not found.
-4 Path was not found.
-9 There was insufficient memory to start the application.
-12 Executable file was invalid. It was not a Windows application or there was an error in the .exe image.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?