Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
run_external_process [2016/10/31 16:28]
admin [Notes]
run_external_process [2026/08/20 03:38] (current)
hermann
Line 1: Line 1:
-====== Run External Process ====== ​+====== Run External Process ======
  
 ===== Description ===== ===== Description =====
  
-This functor ​runs an external ​*.exe*.cmd or batch process.+**RunExternalProcess** ​runs an executable file external ​to Dinamica EGOpassing it the necessary parametersIt can either block the model'​s execution until the process finishes (or for a specified number of seconds), ​or launch the process ​and let the model continue running in parallel with it.
  
 ===== Inputs ===== ===== Inputs =====
  
-^ Name  ^ Type  ^ Description ​ +^ Name ^ Type ^ Description ^ 
-| File Name  | [[String Type]] ​ The executable ​*.exe or *.com file name. If you are using a long file name containing ​spaceuse a double-quoted string +| File Name | [[string_type|String Type]] | Full path of the executable file to run. This port is compact (entered directly rather than via connection). If no extension is given, ''​.exe''​ is appended automatically — except when the name ends in bare ''​.''​ or already includes a directory pathin which case nothing is appended. An executable with different extension (e.g. ''​.com''​) must include it explicitly. Enclose the value in double ​quotes if it contains spaces. | 
-| Parameters ​ | [[String Type]] ​ Process execution ​parameters. ​ |+| Parameters | [[string_type|String Type]] | Parameters passed to the executable. May be left empty if no parameters ​are needed. This port is compact. To run a prompt command or a ''​*.bat''​ file on Windows, set File Name to ''​cmd.exe''​ and Parameters to ''/​c NAME_OF_FILE_OR_COMMAND''​. |
  
 ===== Optional Inputs ===== ===== Optional Inputs =====
  
-^ Name  ^ Type  ^ Description ​ ^ Default Value  ​+^ Name ^ Type ^ Description ^ 
-| Wait Process Completion ​ | [[Boolean Value Type]] ​ | If true, the model waits for termination of the process. ​Otherwise, the model runs parallel ​to the process. ​ | True  ​+| Wait Process Completion | [[boolean_value_type|Boolean Value Type]] | If ''​Yes''​, the model waits for the external ​process ​to finish before continuingIf ''​No''​, the model continues running in parallel ​with the launched ​process. ​The default value is ''​Yes''​. This is an advanced port. 
-| Seconds ​to Wait  | [[Integer Value Type]] ​ The model waits this value (in seconds) to resume. If zero, the model waits for the the process to terminate ​| ​ |+| Seconds ​To Wait | [[integer_value_type|Integer Value Type]] | After launching the process, the number of seconds the model waits before continuing execution. If ''​0''​, the model waits for the process to finish entirelyThe default value is ''​0''​. This is an advanced port. |
  
 ===== Outputs ===== ===== Outputs =====
  
-None.+^ Name ^ Type ^ Description ^ 
 +| Exit Code | [[integer_value_type|Integer Value Type]] | Value returned by the process, if its execution has completedThis output can be ignored. |
  
 ===== Group ===== ===== Group =====
  
-[[Functor List#Control ​| Control]]+[[functor_list#control|Control]]
  
-===== Notes ===== +===== Notes =====
  
-The new process runs in the same Dinamica EGO security context.+==== Executable search order ==== 
 +When File Name has no directory path, the executable is located by searching, ​in order: ​the current directory, ​Dinamica EGO's own directory, the 64-bit Windows system directory, the 32-bit Windows system directory, the 16-bit Windows system directory, and finally the Windows directory itself.
  
-If the given file name does not contain an extension, ".exe" ​is appended. Thereforeif the file name extension is "​.com"​this parameter +==== Waiting behavior ==== 
-must include ​the "​.com"​ extension. If the file name ends in a period "​."​ with no extensionor if the file name contains a path, "​.exe"​ is not appended.+If Wait Process Completion is ''​Yes''​ and Seconds To Wait is ''​0'', ​the model waits indefinitely for the process to finishIf Seconds To Wait is greater than ''​0''​, the model waits only that many seconds and then continuesdetaching from the process (which keeps running). If Wait Process Completion is ''​No''​, the model detaches from the process immediately after launching it.
  
-If the file name does not contain a directory path, the system searches ​for the executable file in the following sequence:+==== Process management ==== 
 +On Windows, system API functions are used to create ​the process, wait for it, close its handles when it finishes, or terminate it if the model is aborted while it is still running. When the model does not wait for the process to finishor the process does not finish within the specified wait time, a background thread is launched to watch for the process'​s termination and to close its handles, or to terminate the process if the model itself is aborted. The process runs in the same security context as Dinamica EGO itself.
  
-  * The current directory; +==== Logging ==== 
-  ​* ​The current directory ​for Dinamica; +The process'​s standard output and standard error are shown in the message log while (and if) the model waits for the process: standard output is logged as INFO, and standard error is logged as ERROR. Standard error is shown in the log only if the process execution returns an errorif it does not, the error output content is not shown.
-  * The 64-bit Windows system directory;​ +
-  * The 32-bit Windows system directory;​ +
-  * The 16-bit Windows system directory;​ +
-  * The Windows directory.+
  
-To run a batch file or a command prompt, you must start the command interpreter;​ set File Name to cmd.exe and set Parameters to the following arguments:​ +===== Internal Name =====
- +
-  /c PROMPT_COMMAND_OR_BATCH_FILE_NAME +
- +
-Where PROMPT_COMMAND_OR_BATCH_FILE_NAME is the command which you want to execute or the complete path and file name of the batch file. +
- +
-The output produced by the process is shown as "​info"​ in the message log, but only if and while the application is blocked waiting for the process execution to complete. +
- +
-Any error output produced by the process is shown as "​error"​ in the message log, but only if the execution of the process itself ends in a error. Otherwise, the error output is ignored. +
- +
-===== Internal Name =====  +
- +
-RunExternalProcess+
  
 +''​RunExternalProcess''​