system
- Updated2023-02-21
- 2 minute(s) read
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 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:
|
Additional Information
Library: ANSI C Library
Include file: ansi_c.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later