Using Visual Studio .NET 2002:
Trying to make a program that will run as a service (but right now implementing it as a forms app) that scan through the running processes looking for one in particular. This process must be closed by a certain time.
In case someone is using the application, I have popped up warnings at a certain time before the process will be killed. But it appears if the person forgot and just left their computer on, everything hangs on the first msgbox, and nothing happens.
Code is below, I'd be gracious.
Trying to make a program that will run as a service (but right now implementing it as a forms app) that scan through the running processes looking for one in particular. This process must be closed by a certain time.
In case someone is using the application, I have popped up warnings at a certain time before the process will be killed. But it appears if the person forgot and just left their computer on, everything hangs on the first msgbox, and nothing happens.
Code is below, I'd be gracious.
VB.NET:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim local As Process() = Process.GetProcesses
Dim i As Integer
Dim tod As String
tod = TimeString()
tod = StrReverse(tod)
tod = tod.Remove(0, 3)
tod = StrReverse(tod)
'MessageBox.Show(tod)
If tod = "10:05" Then
For i = 0 To local.Length - 1
If Strings.UCase(local(i).ProcessName) = Strings.UCase("process") Then
MsgBox("process will shut down in 5 minutes", MsgBoxStyle.Critical, "process")
Else
Me.Close()
End If
Next
ElseIf tod = "10:08" Then
For i = 0 To local.Length - 1
If Strings.UCase(local(i).ProcessName) = Strings.UCase("process") Then
MsgBox("process OM will shut down in 2 minutes")
Else
Me.Close()
End If
Next
ElseIf tod = "10:09" Then
For i = 0 To local.Length - 1
If Strings.UCase(local(i).ProcessName) = Strings.UCase("process") Then
MsgBox("process will shut down in 1 Minute", MsgBoxStyle.Critical, "process")
MsgBox("It Is Recommended that you save your changes immediately", MsgBoxStyle.Critical, "process")
Else
Me.Close()
End If
Next
ElseIf tod = "10:10" Then
For i = 0 To local.Length - 1
If Strings.UCase(local(i).ProcessName) = Strings.UCase("process") Then
local(i).Kill()
End If
Next
Me.Close()
End If
End Sub