Solved

vb.net and WMI - remote process killing

Posted on 2014-10-31
1
147 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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