Hi,
I am running an application perfcalc.exe by sending some parameters through "System.Diagnostics.Process". The purpose is, I want to receive back the exitcode and standard-output. It's working correctly. BUT, I also want to add a timeout limit so if the process taking more than 30 minutes, it will automatically terminate the job. The reason why I need this, the applicaiton perfcalc.exe sometimes get-halt or hold the process, this way the total code cannot get executed and I receive no notification email.
Anyone can help to add the timeout limit to this process?
--
$objProcess = New-Object System.Diagnostics.Process
$objProcess.StartInfo = New-Object System.Diagnostics.ProcessStartInfo
$objProcess.StartInfo.FileName = "c:\apps\perfcalc.exe"
$objProcess.StartInfo.Arguments = "-tSPDF -m\\srvr098\reports\calc.pdf"
$objProcess.StartInfo.UseShellExecute = $shell
$objProcess.StartInfo.WindowStyle = 1
$objProcess.StartInfo.RedirectStandardOutput = $true
$null = $objProcess.Start()
$objProcess.WaitForExit()
$objProcess.ExitCode
$objProcess.StandardOutput.ReadToEnd()
$objProcess.Dispose()
I am running an application perfcalc.exe by sending some parameters through "System.Diagnostics.Process". The purpose is, I want to receive back the exitcode and standard-output. It's working correctly. BUT, I also want to add a timeout limit so if the process taking more than 30 minutes, it will automatically terminate the job. The reason why I need this, the applicaiton perfcalc.exe sometimes get-halt or hold the process, this way the total code cannot get executed and I receive no notification email.
Anyone can help to add the timeout limit to this process?
--
$objProcess = New-Object System.Diagnostics.Process
$objProcess.StartInfo = New-Object System.Diagnostics.ProcessStartInfo
$objProcess.StartInfo.FileName = "c:\apps\perfcalc.exe"
$objProcess.StartInfo.Arguments = "-tSPDF -m\\srvr098\reports\calc.pdf"
$objProcess.StartInfo.UseShellExecute = $shell
$objProcess.StartInfo.WindowStyle = 1
$objProcess.StartInfo.RedirectStandardOutput = $true
$null = $objProcess.Start()
$objProcess.WaitForExit()
$objProcess.ExitCode
$objProcess.StandardOutput.ReadToEnd()
$objProcess.Dispose()