• I removed the www from the URL, please update your bookmarks and pay attention to the bottom of the screen if using Google Chrome to allow push notifications again.

Question Kill a remote process


New member
Oct 25, 2012
Programming Experience
I have searched and search for this answer but everything I try errors out.

I am trying to use WMI to check a Remote/Local network pc if a process is running. If it is, I want to kill the process.

Situation is that we have software that is used in the company called Alliance. We have 10 seats rolling seats. However only 2/3 people need to be in there all day. The problem is when the others use it, they use it for 5 minutes and then leave it open thus blocking others from using it. Then IT gets a call to say they cant get in.

I built a form that the user types in the offending pc name and clicks a check button. It checks if its running on the remote machine and returns an answer. This works 100%.

I then have a button made visible to kill the offending process but i cannot get that part to work.

I would appreciate any direction.

Here is my code so far:

Public Class AllianceCtrl
    Dim strProcess As String
    Dim myP As System.Diagnostics.Process

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCheck.Click

        Dim strAllianceState As String = ""
        Dim strComputer As String = txtPCNAME.Text.ToUpper

            strProcess = "ALLIANCEMFG.EXE"

        Loop Until strProcess <> ""

        Loop Until strComputer <> ""

        myP() = Process.GetProcessesByName(strProcess)
        If (IsProcessRunning(strComputer, strProcess) = True) Then
            strAllianceState = "Alliance is running on " & ControlChars.NewLine & strComputer
            lblAllianceStatus.Text = strAllianceState
            lblAllianceStatus.ForeColor = Color.Red
            btnCloseAlliance.Visible = True
            btnCloseAlliance.Text = "Close Alliance On " & ControlChars.NewLine & strComputer


            strAllianceState = " Alliance is not running on " & ControlChars.NewLine & strComputer
            lblAllianceStatus.Text = strAllianceState
            lblAllianceStatus.ForeColor = Color.Green
            btnCloseAlliance.Visible = False

        End If

    End Sub


    Private Sub btnCloseAlliance_Click(sender As Object, e As EventArgs) Handles btnCloseAlliance.Click


        'If myP.ProcessName = Me.strProcess Then

        '    myP.Kill()

        'End If

    End Sub

    Function IsProcessRunning(ByVal strServer, ByVal strProcess)
        Dim Process, strObject
        IsProcessRunning = False
        strObject = "winmgmts://" & strServer
        For Each Process In GetObject(strObject).InstancesOf("win32_process")
            If UCase(Process.name) = UCase(strProcess) Then
                IsProcessRunning = True
                Exit Function
            End If
    End Function

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click

    End Sub
End Class
Top Bottom