Exec
- Last UpdatedJul 18, 2023
- 1 minute read
Executes an application, LNK file or PIF file (32 bit system only). The application or command starts up and continues to run in parallel with Plant 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 view and the [Security]BlockExec parameter is set to 0. For more information about the Allow Exec role, refer to [Security]BlockExec.
Syntax
Exec(Command [, Mode] )
Command:
The operating system command to execute (maximum of 255 characters).
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") + "^"")