Execute process c windows

execute_processВ¶

Execute one or more child processes.

Runs the given sequence of one or more commands.

Commands are executed concurrently as a pipeline, with the standard output of each process piped to the standard input of the next. A single standard error pipe is used for all processes.

A child process command line.

CMake executes the child process using operating system APIs directly. All arguments are passed VERBATIM to the child process. No intermediate shell is used, so shell operators such as > are treated as normal arguments. (Use the INPUT_* , OUTPUT_* , and ERROR_* options to redirect stdin, stdout, and stderr.)

If a sequential execution of multiple commands is required, use multiple execute_process() calls with a single COMMAND argument.

The named directory will be set as the current working directory of the child processes.

After the specified number of seconds (fractions allowed), all unfinished child processes will be terminated, and the RESULT_VARIABLE will be set to a string mentioning the «timeout».

The variable will be set to contain the result of last child process. This will be an integer return code from the last child or a string describing an error condition.

New in version 3.10.

The variable will be set to contain the result of all processes as a semicolon-separated list , in order of the given COMMAND arguments. Each entry will be an integer return code from the corresponding child or a string describing an error condition.

The variable named will be set with the contents of the standard output and standard error pipes, respectively. If the same variable is named for both pipes their output will be merged in the order produced.

INPUT_FILE, OUTPUT_FILE , ERROR_FILE

The file named will be attached to the standard input of the first process, standard output of the last process, or standard error of all processes, respectively.

New in version 3.3: If the same file is named for both output and error then it will be used for both.

The standard output or standard error results will be quietly ignored.

New in version 3.15.

The command being run will be echo’ed to with being set to one of STDERR , STDOUT or NONE . See the CMAKE_EXECUTE_PROCESS_COMMAND_ECHO variable for a way to control the default behavior when this option is not present.

New in version 3.8.

On Windows, the encoding that is used to decode output from the process. Ignored on other platforms. Valid encoding names are:

Perform no decoding. This assumes that the process output is encoded in the same way as CMake’s internal encoding (UTF-8). This is the default.

Use the current active console’s codepage or if that isn’t available then use ANSI.

Use the ANSI codepage.

Use the original equipment manufacturer (OEM) code page.

Use the UTF-8 codepage.

New in version 3.11: Accept UTF-8 spelling for consistency with the UTF-8 RFC naming convention.

New in version 3.18.

The standard output or standard error will not be exclusively redirected to the configured variables.

The output will be duplicated, it will be sent into the configured variables and also on standard output or standard error.

This is analogous to the tee Unix command.

New in version 3.19.

The option following COMMAND_ERROR_IS_FATAL determines the behavior when an error is encountered:

ANY If any of the commands in the list of commands fail, the execute_process() command halts with an error.

LAST If the last command in the list of commands fails, the execute_process() command halts with an error. Commands earlier in the list will not cause a fatal error.

If more than one OUTPUT_* or ERROR_* option is given for the same pipe the precedence is not specified. If no OUTPUT_* or ERROR_* options are given the output will be shared with the corresponding pipes of the CMake process itself.

The execute_process() command is a newer more powerful version of exec_program() , but the old command has been kept for compatibility. Both commands run while CMake is processing the project prior to build system generation. Use add_custom_target() and add_custom_command() to create custom commands that run at build time.

Execute Process Task

Applies to: SQL Server (all supported versions) SSIS Integration Runtime in Azure Data Factory

The Execute Process task runs an application or batch file as part of a SQL Server Integration Services package workflow. Although you can use the Execute Process task to open any standard application, such as Microsoft Excel or Microsoft Word, you typically use it to run business applications or batch files that work against a data source. For example, you can use the Execute Process task to expand a compressed text file. Then the package can use the text file as a data source for the data flow in the package. As another example, you can use the Execute Process task to run a custom Visual Basic application that generates a daily sales report. Then you can attach the report to a Send Mail task and forward the report to a distribution list.

Integration Services includes other tasks that perform workflow operations such as executing packages. For more information, see Execute Package Task

Custom Log Entries Available on the Execute Process Task

The following table lists the custom log entries for the Execute Process task. For more information, see Integration Services (SSIS) Logging.

Читайте также:  Figma desktop app windows
Log entry Description
ExecuteProcessExecutingProcess Provides information about the process that the task is configured to run.

Two log entries are written. One contains information about the name and location of the executable that the task runs, and the other entry records the exit from the executable.

ExecuteProcessVariableRouting Provides information about which variables are routed to the input and outputs of the executable. Log entries are written for stdin (the input), stdout (the output), and stderr (the error output).

Configuration of the Execute Process Task

You can set properties through SSIS Designer or programmatically.

For more information about how to set these properties in SSIS Designer, click the following topic:

Property Settings

When the Execute Process task runs a custom application, the task provides input to the application through one or both of the following methods:

A variable that you specify in the StandardInputVariable property setting. For more information about variables, see Integration Services (SSIS) Variables and Use Variables in Packages.

An argument that you specify in the Arguments property setting. (For example, if the task opens a document in Word, the argument can name the .doc file.)

To pass multiple arguments to a custom application in one Execute Process task, use spaces to delimit the arguments. An argument cannot include a space; otherwise, the task will not run. You can use an expression to pass a variable value as the argument. In the following example, the expression passes two variable values as arguments, and uses a space to delimit the arguments:

You can use an expression to set various Execute Process task properties.

When you use the StandardInputVariable property to configure the Execute Process task to provide input, call the Console.ReadLine method from the application to read the input. For more information, see Console.ReadLine Methodthe topic, , in the Microsoft .NET Framework Class Library.

When you use the Arguments property to configure the Execute Process task to provide input, do one of the following steps to obtain the arguments:

If you use Microsoft Visual Basic to write the application, set the My.Application.CommandLineArgs property. The following example sets the My.Application.CommandLineArgs property is to retrieve two arguments:

For more information, see the topic, My.Application.CommandLineArgs Property, in the Visual Basic reference.

If you use Microsoft Visual C# to write the application, use the Main method.

For more information, see the topic, Command-Line Arguments (C# Programming Guide), in the C# Programming Guide.

The Execute Process task also includes the StandardOutputVariable and StandardErrorVariable properties for specifying the variables that consume the standard output and error output of the application, respectively.

Additionally, you can configure the Execute Process task to specify a working directory, a time-out period, or a value to indicate that the executable ran successfully. The task can also be configured to fail if the return code of the executable does not match the value that indicates success, or if the executable is not found at the specified location.

Programmatic Configuration of the Execute Process Task

For more information about programmatically setting these properties, click the following topic:

Execute Process Task Editor (General Page)

Use the General pageof the Execute Process Task Editor dialog box to name and describe the Execute Process task.

Options

Name
Provide a unique name for the Execute Process task. This name is used as the label in the task icon.

Task names must be unique within a package.

Description
Type a description of the Execute Process task.

Execute Process Task Editor (Process Page)

Use the Process page of the Execute Process Task Editor dialog box to configure the options that execute the process. These options include the executable to run, its location, command prompt arguments, and the variables that provide input and capture output.

Options

RequireFullFileName
Indicate whether the task should fail if the executable is not found at the specified location.

Executable
Type the name of the executable to run.

Arguments
Provide command prompt arguments.

WorkingDirectory
Type the path of the folder that contains the executable, or click the browse button (. ) and locate the folder.

StandardInputVariable
Select a variable to provide the input to the process, or click to create a new variable:

Related Topics: Add Variable

StandardOutputVariable
Select a variable to capture the output of the process, or click to create a new variable.

StandardErrorVariable
Select a variable to capture the error output of the processor, or click to create a new variable.

FailTaskIfReturnCodeIsNotSuccessValue
Indicate whether the task fails if the process exit code is different from the value specified in SuccessValue.

SuccessValue
Specify the value returned by the executable to indicate success. By default this value is set to 0.

TimeOut
Specify the number of seconds that the process can run. A value of 0 indicates that no time-out value is used, and the process runs until it is completed or until an error occurs.

TerminateProcessAfterTimeOut
Indicate whether the process is forced to end after the time-out period specified by the TimeOut option. This option is available only if TimeOut is not 0.

WindowStyle
Specify the window style in which to run the process.

Задача «Выполнение процесса» Execute Process Task

Применимо к: Applies to: SQL Server SQL Server (все поддерживаемые версии) SQL Server SQL Server (all supported versions) Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Применимо к: Applies to: SQL Server SQL Server (все поддерживаемые версии) SQL Server SQL Server (all supported versions) Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory

Задача «Выполнение процесса» запускает приложение или пакетный файл в составе рабочего процесса пакета служб SQL Server SQL Server Службы Integration Services Integration Services . The Execute Process task runs an application or batch file as part of a SQL Server SQL Server Службы Integration Services Integration Services package workflow. Хотя задача «Выполнение процесса» может использоваться для выполнения любого стандартного приложения, такого как Microsoft Excel Microsoft Excel или Microsoft Word Microsoft Word , обычно она применяется для запуска бизнес-приложений или командных файлов, работающих с источником данных. Although you can use the Execute Process task to open any standard application, such as Microsoft Excel Microsoft Excel or Microsoft Word Microsoft Word , you typically use it to run business applications or batch files that work against a data source. Например, задачу «Выполнение процесса» можно использовать для развертывания сжатого текстового файла. For example, you can use the Execute Process task to expand a compressed text file. Потом пакет сможет использовать текстовый файл в качестве источника данных для потока данных в пакете. Then the package can use the text file as a data source for the data flow in the package. Или, например, задача «Выполнение процесса» может использоваться для запуска приложения Visual Basic Visual Basic , создающего ежедневный отчет о продажах. As another example, you can use the Execute Process task to run a custom Visual Basic Visual Basic application that generates a daily sales report. Затем можно присоединить отчет к задаче «Отправка почты» и разослать отчет по списку распространения. Then you can attach the report to a Send Mail task and forward the report to a distribution list.

Службы Integration Services Integration Services содержат другие задачи, которые выполняют операции рабочего процесса, такие как исполнение пакетов. includes other tasks that perform workflow operations such as executing packages. Дополнительные сведения см. в разделе Execute Package Task. For more information, see Execute Package Task

Пользовательские записи журнала, доступные в задаче «Выполнение процесса» Custom Log Entries Available on the Execute Process Task

В следующей таблице перечислены пользовательские записи в журнале для задачи «Выполнение процесса». The following table lists the custom log entries for the Execute Process task. Дополнительные сведения см. в разделе Ведение журналов в службах Integration Services (SSIS). For more information, see Integration Services (SSIS) Logging.

Запись журнала Log entry Description Description
ExecuteProcessExecutingProcess ExecuteProcessExecutingProcess Предоставляет сведения о процессе, для запуска которого настроена задача. Provides information about the process that the task is configured to run.

В журнале формируются две записи. Two log entries are written. Одна из них предоставляет сведения об имени и месте выполнения исполняемого объекта, на запуск которого настроена задача, другая фиксирует выход из исполняемого объекта. One contains information about the name and location of the executable that the task runs, and the other entry records the exit from the executable.

ExecuteProcessVariableRouting ExecuteProcessVariableRouting Предоставляет сведения о том, какие переменные направляются на вход и выходы исполняемого объекта. Provides information about which variables are routed to the input and outputs of the executable. Данные журнала записываются для потоков stdin (вход), stdout (выход) и stderr (вывод ошибок на выходе). Log entries are written for stdin (the input), stdout (the output), and stderr (the error output).

Настройка задачи «Выполнение процесса» Configuration of the Execute Process Task

Значения свойств можно задавать с помощью конструктора Integration Services SSIS или программными средствами. You can set properties through Integration Services SSIS Designer or programmatically.

Дополнительные сведения об установке этих свойств в конструкторе служб Integration Services SSIS см. в следующем разделе: For more information about how to set these properties in Integration Services SSIS Designer, click the following topic:

Параметры свойств Property Settings

Если задача «Выполнение процесса» запускает пользовательское приложение, она предоставляет входные данные для приложения с помощью одного или обоих следующих методов. When the Execute Process task runs a custom application, the task provides input to the application through one or both of the following methods:

Переменной, указанной в свойстве StandardInputVariable . A variable that you specify in the StandardInputVariable property setting. Дополнительные сведения о переменных см. в разделах Переменные в службах Integration Services (SSIS) и Использование переменных в пакетах. For more information about variables, see Integration Services (SSIS) Variables and Use Variables in Packages.

Аргумента, указанного в параметре Arguments . An argument that you specify in the Arguments property setting. Например, если задача открывает документ в приложении Word, то аргументом может быть имя DOC-файла. (For example, if the task opens a document in Word, the argument can name the .doc file.)

При передаче нескольких аргументов в пользовательское приложение в одной задаче «Выполнение процесса» используйте пробелы для разделения аргументов. To pass multiple arguments to a custom application in one Execute Process task, use spaces to delimit the arguments. Аргумент не может содержать пробел, иначе задача не будет выполняться. An argument cannot include a space; otherwise, the task will not run. Можно использовать выражение для передачи значения переменной в качестве значения аргумента. You can use an expression to pass a variable value as the argument. В следующем примере выражение передает два значения переменных в качестве аргументов и использует пробел для разделения аргументов: In the following example, the expression passes two variable values as arguments, and uses a space to delimit the arguments:

Можно использовать выражение, чтобы задать различные свойства задачи «Выполнение процесса». You can use an expression to set various Execute Process task properties.

При использовании свойства StandardInputVariable для настройки задачи «Выполнение процесса» на предоставление входных данных, вызовите метод Console.ReadLine из приложения, чтобы считать входные данные. When you use the StandardInputVariable property to configure the Execute Process task to provide input, call the Console.ReadLine method from the application to read the input. Дополнительные сведения см. в разделе Console.ReadLine Methodв библиотеке классов платформы Microsoft Microsoft .NET Framework .NET Framework . For more information, see Console.ReadLine Methodthe topic, , in the Microsoft Microsoft .NET Framework .NET Framework Class Library.

При использовании свойства Аргументы для настройки задачи «Выполнение процесса» на предоставление входных данных выполните одно из следующих действий, чтобы получить аргументы. When you use the Arguments property to configure the Execute Process task to provide input, do one of the following steps to obtain the arguments:

Если для написания приложения используется Microsoft Visual Basic, задайте свойство My.Application.CommandLineArgs . If you use Microsoft Visual Basic to write the application, set the My.Application.CommandLineArgs property. В следующем примере устанавливается свойство My.Application.CommandLineArgs , чтобы получить два аргумента. The following example sets the My.Application.CommandLineArgs property is to retrieve two arguments:

Дополнительные сведения см. в разделе My.Application.CommandLineArgs Property, в справочнике Visual Basic Visual Basic . For more information, see the topic, My.Application.CommandLineArgs Property, in the Visual Basic Visual Basic reference.

Если для подготовки приложения применяется Microsoft Visual C#, используйте метод Main. If you use Microsoft Visual C# to write the application, use the Main method.

Дополнительные сведения см. в разделе Command-Line Arguments (C# Programming Guide)в руководстве по программированию на C#. For more information, see the topic, Command-Line Arguments (C# Programming Guide), in the C# Programming Guide.

Задача «Выполнение процесса» также содержит свойства StandardOutputVariable и StandardErrorVariable , чтобы указать переменные, которые используют стандартное устройство вывода и вывод ошибок приложения соответственно. The Execute Process task also includes the StandardOutputVariable and StandardErrorVariable properties for specifying the variables that consume the standard output and error output of the application, respectively.

Кроме того, задача «Выполнение процесса» может быть настроена для указания рабочего каталога, времени ожидания или значения, указывающего, что исполняемый объект был запущен успешно. Additionally, you can configure the Execute Process task to specify a working directory, a time-out period, or a value to indicate that the executable ran successfully. Задача также может быть настроена на завершение со сбоем, если код возврата исполняемого объекта не соответствует значению успешного выполнения или если исполняемый объект не найден в указанном месте. The task can also be configured to fail if the return code of the executable does not match the value that indicates success, or if the executable is not found at the specified location.

Настройка задачи «Выполнение процесса» с помощью программных средств Programmatic Configuration of the Execute Process Task

Дополнительные сведения об установке этих свойств программными средствами см. в следующем разделе. For more information about programmatically setting these properties, click the following topic:

Редактор задачи «Выполнение процесса» (страница «Общие») Execute Process Task Editor (General Page)

Воспользуйтесь страницей Общие диалогового окна Редактор задачи «Выполнение процесса» для ввода имени и описания задачи «Выполнение процесса». Use the General pageof the Execute Process Task Editor dialog box to name and describe the Execute Process task.

Параметры Options

имя; Name
Введите уникальное имя для задачи «Выполнение процесса». Provide a unique name for the Execute Process task. Это имя используется в качестве метки для значка задачи. This name is used as the label in the task icon.

Имена задач в пределах пакета должны быть уникальными. Task names must be unique within a package.

Описание Description
Введите описание задачи «Выполнение процесса». Type a description of the Execute Process task.

Редактор задачи «Выполнение процесса» (страница «Процесс») Execute Process Task Editor (Process Page)

Страница Процесс диалогового окна Редактор задачи «Выполнение процесса» позволяет настраивать параметры выполнения процесса. Use the Process page of the Execute Process Task Editor dialog box to configure the options that execute the process. Эти параметры включают исполняемый объект, его расположение, аргументы командной строки и переменные для входных и выходных данных. These options include the executable to run, its location, command prompt arguments, and the variables that provide input and capture output.

Параметры Options

Требуется полное имя файла RequireFullFileName
Указывает, закончится ли задача ошибкой, если исполняемый объект не найден в указанном месте. Indicate whether the task should fail if the executable is not found at the specified location.

Исполняемый объект Executable
Введите имя исполняемого модуля. Type the name of the executable to run.

Аргументы Arguments
Введите аргументы командной строки. Provide command prompt arguments.

WorkingDirectory WorkingDirectory
Введите путь к папке, содержащей исполняемый объект, или нажмите кнопку обзора (. ) и укажите эту папку. Type the path of the folder that contains the executable, or click the browse button (. ) and locate the folder.

StandardInputVariable StandardInputVariable
Выберите переменную для ввода данных для этого процесса или щелкните пункт для создания новой переменной: Select a variable to provide the input to the process, or click to create a new variable:

См. также: Добавить переменную Related Topics: Add Variable

StandardOutputVariable StandardOutputVariable
Выберите переменную для вывода данных из этого процесса или щелкните пункт для создания новой переменной. Select a variable to capture the output of the process, or click to create a new variable.

StandardErrorVariable StandardErrorVariable
Выберите переменную для получения сведений об ошибках этого процессора или щелкните пункт для создания новой переменной. Select a variable to capture the error output of the processor, or click to create a new variable.

FailTaskIfReturnCodeIsNotSuccessValue FailTaskIfReturnCodeIsNotSuccessValue
Укажите, должна ли задача завершаться с ошибкой, если код завершения отличен от кода, указанного в параметре SuccessValue. Indicate whether the task fails if the process exit code is different from the value specified in SuccessValue.

SuccessValue SuccessValue
Укажите значение, возвращаемое исполняемым объектом при успешном завершении задачи. Specify the value returned by the executable to indicate success. По умолчанию, устанавливается значение 0. By default this value is set to 0.

Время ожидания TimeOut
Указывает число секунд, в течение которых может выполняться данный процесс. Specify the number of seconds that the process can run. Значение 0 показывает, что значение времени ожидания не используется и процесс выполняется до завершения или сбоя. A value of 0 indicates that no time-out value is used, and the process runs until it is completed or until an error occurs.

TerminateProcessAfterTimeOut TerminateProcessAfterTimeOut
Указывает, должен ли процесс быть принудительно остановлен по истечении времени, обозначенного в параметре TimeOut . Indicate whether the process is forced to end after the time-out period specified by the TimeOut option. Этот параметр доступен только при значении параметра Время ожидания , отличном от 0. This option is available only if TimeOut is not 0.

WindowStyle WindowStyle
Указывает стиль окна, в котором выполняется процесс. Specify the window style in which to run the process.

Читайте также:  Ошибка 0x8007001f 0x20006 при обновлении windows
Оцените статью