I have a program that needs to kill any previous instances of itself whenever it is opened.
I'm using the following code...
Dim processes As Process
Dim temp As Byte, x As Byte
Dim tempProcess(5) As Process : Dim TempProcessTime As DateTime
For Each processes In Process.GetProcesses
If processes.ToString = "System.Diagnostics.Process (SipcaEMR)" Then temp = temp + 1 : tempProcess(temp) = processes : If DateDiff(DateInterval.Second, processes.StartTime, TempProcessTime) < 0 Then TempProcessTime = processes.StartTime
If temp > 1 Then
For x = 1 To temp
If Not tempProcess(x).StartTime = TempProcessTime Then tempProcess(x).Kill()
This works fine on my Fat Clients.
The problem is that this will not work on a terminal server because it will kill of the processes of all the users using this application. I want it to only kill off and previously opened SipcaEMR that this user is running. Leaving the rest alone