Solved

vb.net and WMI - remote process killing

Posted on 2014-10-31
1
145 Views
Last Modified: 2014-10-31
Attempting to kill a remote process using vb.net and wmi.  I can query the processes fine and is a specify a process ID to kill, it works fine, but when i try and set the process id as variable it fails.  Assuming it fails because im not calling the selecteditem properly:

Dim RC As String = TextBox1.Text
        Dim taskID As String = listview2.selecteditems (doesnt work), (when i replace with "4784", it works)

        Dim theScope As New ManagementScope("\\" & RC & "\root\cimv2")
        Dim objectQuery As New ObjectQuery(String.Concat("SELECT * FROM Win32_Process WHERE ProcessID='", taskID, "'"))
        For Each managementObject As ManagementObject In (New ManagementObjectSearcher(theScope, objectQuery)).[Get]()
            managementObject.InvokeMethod("Terminate", Nothing)
        Next
    End Sub

Open in new window

0
Comment
Question by:derek7467
1 Comment
 

Accepted Solution

by:
derek7467 earned 0 total points
ID: 40416715
believe I figured it out, should have used google a bit more:

ListView1.FocusedItem.Text
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question