In a ps1 file I start 2 separate processes like so: As you can see the only difference is the CPU affinity.
$Process1 = Start-Process -FilePath 'C:\Windows\system32\notepad.exe' -PassThru
$Process1.ProcessorAffinity = 65535
$Process1.PriorityClass = 'RealTime'
$Process2 = Start-Process -FilePath 'C:\Windows\system32\notepad.exe' -PassThru
$Process2.ProcessorAffinity = 4294901760
$Process2.PriorityClass = 'RealTime'
Sometimes, randomly, one of the 2 processes fails with: Problem Event Name: BEX64
It is essential that the process is restarted immediately when a failure like this happens. So I am faced with this problem.
Can I monitor within the PS1 file the 2 processes and if one fails to restart it? The monitoring process must be able to distinguish which of the 2 processes has failed, so that the correct affinity is used to restart it.
If you have a solution involving windows batch script please visit How to RESTART a specific command if it fails in Windows Batch file?
Thanks
Process.ProcessorAffinityis a bitmask representing the CPUs, so using decimal for it makes zero sense. Use$Process1.ProcessorAffinity = 0xFFFFinstead of 65535