Kill Remote Computer Process in

Good Morning All! Everyone was gone this weekend which meant I had a very quiet weekend. Did some WPF study but not whole lot of other things.

Anyway what we want to do is kill a process on a remote PC using WMI. It actually was pretty challenging. Don’t forget you will need to allow permissions for this! But anyway, make it a great day!

Private Sub cmdKill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKill.Click
        strComputer = txtPC.Text
        strDomain = <Domain>
        strProcessKill = "’" & listProcess.SelectedItem & ".exe’"
        objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessKill)
        For Each objProcess In colProcess
    End Sub


Technorati Tags: ,,,,,,,,,,,,,,,,,,,,,,

Windows Live Tags:,.NET Framework,csharp,cimv2,root,impersonate,impersonationLevel,winmgmts,WMI,process,Kill,Remote,Computer,Object,Text,Domain,SelectedItem,GetObject,ExecQuery,Select,Where,Name,Terminate

  1. #1 by Richard on January 7, 2009 - 7:31 am

    Hello Kelly,Thank you for this example! I have some questions:1. Could this be done using classes in the System.Management namespace?2. Is it correct to assume that objWMIService, colProcess, and objProcess are to declared as type Object?3. If so, will this work with Option Strict On without casting to specific types?Thanks again, Rich.

  2. #2 by Kelly on January 7, 2009 - 8:40 am

    1. Yes (This is WMI) 2. Yes 3. I don\’t know to be honest. I know I should keep strict on but for these purposes I often do not.I don\’t know why they didn\’t notify me about your post. It is also possible it ended up in junk mail and I skipped over it.

  3. #3 by vishal on April 25, 2011 - 6:55 pm

    how to give access permision?

  4. #5 by Laurent on May 24, 2013 - 12:38 pm

    Thanks very usefull !

    Private Sub killRemoteProcess(remoteComputer As String, processName As String)

    Dim objWMIService,colProcess,objProcess As Object

    objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & remoteComputer & “\root\cimv2”)

    colProcess = objWMIService.ExecQuery(“Select * from Win32_Process Where Name = ” & “‘” & processName & “.exe'”)

    For Each objProcess In colProcess

    End Sub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: