hendrikbez
Active member
I have a few processes that does stop and start again, but this do nothing, I open the server with ultravnc to see thes screen, then I run my program, then I try to stop one of the osmons, but it does not close the screen. if I close the osmon myself on the serer, and I try to start it with my program, it does not start it. it is only the osmons that don't stop ort start, I don't know if the code is correct 100%
I have each of this lines in a separate batch file
osmon1.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=DEFAULT
osmon2.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON2
osmon3.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON3
osmon4.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON4
osmon5.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON5
I am trying to make a process to stop and start each process by itself
Each one of them use osmon.exe to start.
I have a client and server, all my other processes are working, but I can not get this to work.
Here are some of my code (on my Server Site) my client side is working
I have each of this lines in a separate batch file
osmon1.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=DEFAULT
osmon2.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON2
osmon3.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON3
osmon4.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON4
osmon5.bat start this one
E:\OSB5.0\OSB\BIN\osmon NAME=OSMON5
I am trying to make a process to stop and start each process by itself
Each one of them use osmon.exe to start.
I have a client and server, all my other processes are working, but I can not get this to work.
Here are some of my code (on my Server Site) my client side is working
VB.NET:
Private Sub KillProcess(ByVal ProcessName As String)
For Each PR As Process In Process.GetProcesses()
If PR.ProcessName = ProcessName Then
PR.Kill()
Exit For
End If
Next PR
End Sub
Private Sub SpecialProcess(ByVal FileName As String, ByVal Domain As String)
If Not IO.File.Exists(FileName) Then MsgBox("File wasn't found .") : Exit Sub
Dim PR As New Process
PR.StartInfo.FileName = FileName
PR.StartInfo.Domain = Domain
PR.Start()
End Sub
Private Sub killprocess(ByVal processname As String, ByVal domain As String)
For Each PR As Process In Process.GetProcesses()
If PR.ProcessName = processname And PR.StartInfo.Domain = domain Then
PR.Kill()
Exit For
End If
Next PR
End Sub
VB.NET:
Private Sub StartMethod()
_TcpListener = New TcpListener(_Port)
_TcpListener.Start() ' Start Listening on That Port
_Socket = _TcpListener.AcceptSocket()
_NetworkStream = New NetworkStream(_Socket)
_StreamReader = New StreamReader(_NetworkStream)
Dim Command As String = _StreamReader.ReadLine()
Select Case Command.ToUpper()
Case "STOPOSMON1"
KillProcess("osmon", "DEFAULT") 'Stop Osmon 1
Case "STOPOSMON2"
KillProcess("osmon", "OSMON2") 'Stop Osmon 2
Case "STOPOSMON3"
KillProcess("osmon", "OSMON3") 'Stop Osmon 3
Case "STOPOSMON4"
KillProcess("osmon", "OSMON4") 'Stop Osmon 4
Case "STOPOSMON5"
KillProcess("osmon", "OSMON5") 'Stop Osmon 5
Case "STARTOSMON1"
SpecialProcess("e:\osb5.0\osb\bin\osmon.exe", "DEFAULT") 'Start Osmon 1
Case "STARTOSMON2"
SpecialProcess("e:\osb5.0\osb\bin\osmon.exe", "OSMON2") 'Start Osmon 2
Case "STARTOSMON3"
SpecialProcess("e:\osb5.0\osb\bin\osmon.exe", "OSMON3") 'Start Osmon 3
Case "STARTOSMON4"
SpecialProcess("e:\osb5.0\osb\bin\osmon.exe", "OSMON4") 'Start Osmon 4
Case "STARTOSMON5"
SpecialProcess("e:\osb5.0\osb\bin\osmon.exe", "OSMON5") 'Start Osmon 5
Case "STARTNOTEPAD"
Process.Start("notepad.exe")
Case "STOPNOTEPAD"
KillProcess("notepad")
End Select
_TcpListener.Stop()
If _Socket.Connected = True Then
Do While True
StartMethod()
Loop
End If
End Sub