vb.net - List remote processes and get description of process

fruitloopy
fruitloopy used Ask the Experts™
on
I have put together some code that gathers the running processes of a remote computer but I would like it to also get the description of the process. I.e. Iexplore.exe = Internet Explorer.

Here's my code so far:
Imports System.Diagnostics
Imports System.Collections


Public Class Processes
    
    Private Sub Processes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim Process As New Process()
        Dim Count As Integer = 0
        ListView1.Items.Clear()
        For Each Process In Process.GetProcesses(Main.txtHostName.Text)
            On Error Resume Next
            ListView1.Items.Add(Process.ProcessName)
            ListView1.Items(Count).SubItems.Add(FormatNumber(Math.Round(Process.PrivateMemorySize64 / 1024), 0))
            ListView1.Items(Count).SubItems.Add(Process.Id)
            ListView1.Items(Count).SubItems.Add(ProductName)
            'ListView1.Items(Count).SubItems.Add(Process.Id)
            Count += 1
            AddHandler Me.ListView1.ColumnClick, AddressOf ColumnClick
        Next
        ToolStripStatusLabel1.Text = "Processes: " & ListView1.Items.Count
    End Sub

    'Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
    '    For Each Process As ListViewItem In ListView1.SelectedItems
    '        System.Diagnostics.Process.GetProcessById(Process.SubItems(3).Text).Kill()
    '    Next
    '    Processes_Load(Nothing, Nothing)
    'End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Processes_Load(Nothing, Nothing)
    End Sub

    ' ColumnClick event handler. 
    Private Sub ColumnClick(ByVal o As Object, ByVal e As ColumnClickEventArgs)
        ' Set the ListViewItemSorter property to a new ListViewItemComparer 
        ' object. Setting this property immediately sorts the 
        ' ListView using the ListViewItemComparer object. 

        'Change this based on which direction you want
        Dim blnAscending As Boolean = True
        Me.listView1.ListViewItemSorter = New ListViewItemComparer(e.Column, blnAscending)
    End Sub

    ' Implements the manual sorting of items by columns. 
    Class ListViewItemComparer
        Implements IComparer

        Private col As Integer
        Private AscOrder As Boolean

        Public Sub New()
            col = 0
            AscOrder = True
        End Sub

        Public Sub New(ByVal column As Integer, ByVal Ascending As Boolean)
            col = column
            AscOrder = Ascending
        End Sub

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
            Implements IComparer.Compare
            If AscOrder Then
                Return [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
            Else
                Return [String].Compare(CType(y, ListViewItem).SubItems(col).Text, CType(x, ListViewItem).SubItems(col).Text)
            End If
        End Function
    End Class

End Class

Open in new window


It would be great to also End the process remotely and refresh the results if that's possible?

I'm learning vb.net as I'm working on this project so please keep it simple for me!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Use the below code.

    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo =
        FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\Iexplore.exe");

    // Print the file description.
    textBox1.Text = "File description: " + myFileVersionInfo.FileDescription;

Author

Commented:
Thanks Gottler. That code would only gather the info for Iexplore.exe though.
How do I change my code above to fetch the description of every process gathered from the remote machine and place it into a listview column?
Populate each process description in the Description column

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial