Cicode Programming Reference > Cicode Function Categories > Miscellaneous Functions Introduction > Exec

Exec

Executes an application or PIF file. The application or command starts up and continues to run in parallel with CitectSCADA.

This function can return while the application is still starting up, so you should use the Sleep() function to allow the application enough time to start.

Syntax

Exec(Command [, Mode] )

Command:

The operating system command to execute.

Mode:

The mode of the window:

1 - Normal

3 - Maximized

6 - Minimized

If you do not enter a mode, the default mode is 1.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

Sleep

Example

Exec("c:\winnt\system32\mspaint.exe");
! Starts up the Paint application with a normal window.
Exec("cmd /c mkdir c:\test");
! Uses the DOS shell to create a new directory

you need to quote paths and applications passed to the exec function (using ^" to embed quotes) so that the function can be executed correctly when long file names are used. For example:

Exec(PathToStr("^"" + "[BIN]:\Ctcicode")+ "^" ^"" + 
PathToStr("[RUN]:\cicode.ci") + "^"")

creates a command line that ends up as:

C:\Program Files\CitectSCADA\CitectSCADA 7.10\Bin\CtCicode C:\Program Files\CitectSCADA\CitectSCADA 7.10\Project\Cicode.ci

See Also

Miscellaneous Functions