?
Solved

vb.net and WMI - remote process killing

Posted on 2014-10-31
1
Medium Priority
?
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 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