PowerShell 1.0 Start-Process not waiting for complete when user logged off PowerShell 1.0 Start-Process not waiting for complete when user logged off powershell powershell

PowerShell 1.0 Start-Process not waiting for complete when user logged off


You still have the .net way of starting a process and waiting for his death. Have a look to the Process class, methods and properties.

## Start a process$Proc = [Diagnostics.Process]::Start("calc.exe")## Start a processus with param$Proc = [Diagnostics.Process]::Start("notepad.exe", "Fic.txt")## Wait for a process death$Proc.WaitForExit()

You can also configure the starting environment

$credential = Get-Credential$startInfo = New-Object Diagnostics.ProcessStartInfo$startInfo.UserName = $credential.Username$startInfo.Password = $credential.Password$startInfo.Filename = "powershell"## Start a process with StartInfo $startInfo.UseShellExecute = $false$Proc = [Diagnostics.Process]::Start($startInfo)## Stop the process$Proc.Kill()