Start-Process
noun
say it: “START PROH-ses” /ˈstɑrt ˈprɑsɛs/
A PowerShell command that starts a program, or opens a file in its own app, with options to hide its window, wait for it, keep hold of it, or run it as administrator.
What does Start-Process do?
Start-Process starts a program the way a job needs it. Give it a file and it opens in the app a double-click would use; give it a program and -ArgumentList hands it its arguments. -PassThru hands back the process so it never gets lost, -Wait waits for it to finish, and -Verb RunAs asks for administrator rights.
Start-Process -FilePath .\report.html # opens in the web browser
$backup = Start-Process -FilePath pwsh -ArgumentList '-NoProfile', '-File', '.\backup.ps1' -NoNewWindow -Wait -PassThru
$backup.ExitCode # 0: it worked
In a sentence
- “Start-Process opened the weekly report in the web browser, the way a double-click would.”
- “With -Wait and -PassThru, Start-Process let the script read the backup's exit code.”
Level: Journeyman · More PowerShell terms at this level
Updated