pc.processes runs commands and programs as the session’s user, on its desktop. The user has administrator rights.
r = pc.processes.run("Get-ChildItem $env:USERPROFILE | Select-Object -First 5")
print(r.exit_code, r.stdout)

pid = pc.processes.start("notepad.exe")

processes.run()

Run a command to completion, with no window, and return its exit code and output.
processes.run(command, *, args=None, shell="powershell", cwd=None, env=None, stdin=None, timeout=None)
ParameterTypeDefaultDescription
commandstrrequiredThe command line, or the program to run with shell="none".
argslist[str] | NoneNoneArguments, with shell="none".
shellstr"powershell""powershell", "cmd", or "none" to run command as a program with args.
cwdstr | Nonethe user’s home folderWorking folder.
envdict[str, str] | NoneNoneExtra environment variables.
stdinstr | NoneNoneText sent to the command’s input.
timeoutfloat | None30000Milliseconds, at most 600,000. The process is killed when it runs out.
Returns 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.
processes.start(command, *, args=None, shell="none", cwd=None, env=None)
Same parameters as 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.
processes.kill(pid)
Raises InvalidArgsError for Windows’ own processes and the session’s agent and streamer, which can’t be ended.

RunResult

How a run() ended. A dataclass.
FieldTypeDescription
exit_codeintThe exit code; -1 when it timed out.
stdout, stderrstrThe output, the first 1 MiB of each.
duration_msintHow long it ran.
timed_outboolWhether timeout ran out and the process was killed.
stdout_truncated, stderr_truncatedboolWhether that stream was longer than 1 MiB.

result.ok

Returns True when exit_code is 0 and it didn’t time out.