How can I start a process, pause for 2 hours and then kill a process in Powershell

Viewed 4244

How can I start a process, pause for 2 hours and then kill a process in Powershell. I can get it to launch the process and kill the process but the Start-Sleep command doesn't seem to be working in my script. I thought this would be simple. Not sure if I'm missing something or if this is even possible to sleep for 2 hours.

if((Get-Process -Name test -ErrorAction SilentlyContinue) -eq $null){
."C:\Program Files (x86)\test.exe" Start-Sleep -s 7200 Stop-Process -name test}
2 Answers
Related