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

Exec

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

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.

Note: Users can run this function only if their Allow Exec role is set to TRUE in the Security | Roles window and the [Security]BlockExec parameter is set to 0. For more information about the Allow Exec role, refer to the Citect SCADA help. For more information about the [Security]BlockExec parameter, refer to the Parameters help.

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\ CitectFacilities\CitectFacilities 7.30\Bin\CtCicode C:\Program Files\CitectFacilities\CitectFacilities 7.30\Project\Cicode.ci Schneider Electric\Vijeo Citect\Vijeo Citect 7.30\Bin\CtCicode C:\Program Files\Schneider Electric\Vijeo Citect\Vijeo Citect 7.30\Project\Cicode.ciSchneider Electric\PowerSCADA Expert 7.30\Bin\CtCicode C:\Program Files\Schneider Electric\PowerSCADA Expert 7.30\Project\Cicode.ci

See Also

Miscellaneous Functions

Published June 2018