master
md 34 lines 921 Bytes
Rendered Raw
1 # ProcessSettings
2
3 **Properties**
4
5 - `WorkingDirectory()` / setter
6 - `CommandLine()` / setter
7 - `EnvironmentVariables()` / setter
8 - `OutputMode()` / setter
9
10 **Important notes**
11
12 - `CommandLine(nullptr)` and `EnvironmentVariables(nullptr)` are rejected.
13 - `Process::Start()` later requires a **non-empty** `CommandLine()`.
14 - `ProcessOutputMode::Event` installs C callbacks; `ProcessOutputMode::Stream` expects stream access; `Discard` is the default.
15
16 ```cpp
17 using namespace winrt::Windows::Foundation::Collections;
18
19 ProcessSettings procSettings;
20 procSettings.WorkingDirectory(L"/workspace");
21 procSettings.OutputMode(ProcessOutputMode::Event);
22
23 auto cmd = single_threaded_vector<hstring>();
24 cmd.Append(L"/bin/sh");
25 cmd.Append(L"-lc");
26 cmd.Append(L"echo hello");
27 procSettings.CommandLine(cmd);
28
29 auto env = single_threaded_map<hstring, hstring>();
30 env.Insert(L"DEMO", L"1");
31 procSettings.EnvironmentVariables(env);
32 ```
33
34 ---