How to auto start new process after the previous process terminated?

215 views Asked by At

I'm capturing the memory dump when w3wp reaches the memory threshold via cmd/Powershell.

The problem here is that the process of cmd/Powershell auto terminates after some hours and did not capture any dump as did not reach the memory threshold.

process [7784] terminated! Press ENTER to start a new cmd process.

I have to run it again

So do you know how to restart/re-run the command after the old cmd/Powershell process terminated?

My command is simple here

procdump -accepteula -ma 5246 -m 13312 -s 5 -n 1 D:\home\Logfiles\

Thank you.

1

There are 1 answers

0
Wasif On

You are looking for Wait-Process.

The Wait-Process cmdlet waits for one or more running processes to be stopped before accepting input. In the PowerShell console, this cmdlet suppresses the command prompt until the processes are stopped. You can specify a process by process name or process ID (PID), or pipe a process object to Wait-Process.

Wait-Process works only on processes running on the local computer.

In this case your script will be:

Wait-Process -Id 7784
& "procdump.exe" -accepteula -ma 5246 -m 13312 -s 5 -n 1 D:\home\Logfiles\