pc.processes runs commands and programs as the session’s user, on its
desktop. The user has administrator rights.
processes.run()
Run a command to completion, with no window, and return its exit code and output.
| Parameter | Type | Default | Description |
|---|---|---|---|
command | str | required | The command line, or the program to run with shell="none". |
args | list[str] | None | None | Arguments, with shell="none". |
shell | str | "powershell" | "powershell", "cmd", or "none" to run command as a program with args. |
cwd | str | None | the user’s home folder | Working folder. |
env | dict[str, str] | None | None | Extra environment variables. |
stdin | str | None | None | Text sent to the command’s input. |
timeout | float | None | 30000 | Milliseconds, at most 600,000. The process is killed when it runs out. |
RunResult. A command that fails returns its exit code; it doesn’t raise.
processes.start()
Start a program and return its process id at once. A program with a window
opens it on the desktop.
run(), but shell defaults to "none".
Returns int: the process id.
processes.list()
The running processes.
Returns list[dict], each {"pid", "parentPid", "name"}.
processes.kill()
End one process.
InvalidArgsError for Windows’ own processes and the session’s agent
and streamer, which can’t be ended.
RunResult
How arun() ended. A dataclass.
| Field | Type | Description |
|---|---|---|
exit_code | int | The exit code; -1 when it timed out. |
stdout, stderr | str | The output, the first 1 MiB of each. |
duration_ms | int | How long it ran. |
timed_out | bool | Whether timeout ran out and the process was killed. |
stdout_truncated, stderr_truncated | bool | Whether that stream was longer than 1 MiB. |
result.ok
Returns True when exit_code is 0 and it didn’t time out.