Results 1 to 2 of 2

Thread: Enumerate Running Processes With X-Treme Details Using WMI :D

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Arrow Enumerate Running Processes With X-Treme Details Using WMI :D

    I figured this out in order to answer a thread on how to use WMI. Its quite simple once you know
    where to look.


    Description:
    This example shows how to enumerate the running processes, like shown in the Task Manager, with complete details
    about each process

    There are 3 formats for the details. The "TextFormat.Mof" is the most readable. It resembles C# whereas the
    other two - "TextFormat.CimDtd20" & "TextFormat.WmiDtd20" give an HTML style listing.

    You can parse out the properties that most pertain to your needs but this gives you everything that you could possibly
    want (I hope ).


    Requirements:
    Add a reference to System.Management

    Tested on:
    VB.NET 2003


    Enjoy





    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3. 'Add a reference to System.Management
    4.  
    5. Imports System.Management
    6.  
    7. Public Class Form1
    8.     Inherits System.Windows.Forms.Form
    9.  
    10. #Region " Windows Form Designer generated code "
    11.     Public Sub New()
    12.         MyBase.New()
    13.         'This call is required by the Windows Form Designer.
    14.         InitializeComponent()
    15.         'Add any initialization after the InitializeComponent() call
    16.     End Sub
    17.  
    18.     'Form overrides dispose to clean up the component list.
    19.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    20.         If disposing Then
    21.             If Not (components Is Nothing) Then
    22.                 components.Dispose()
    23.             End If
    24.         End If
    25.         MyBase.Dispose(disposing)
    26.     End Sub
    27.  
    28.     'Required by the Windows Form Designer
    29.     Private components As System.ComponentModel.IContainer
    30.     'NOTE: The following procedure is required by the Windows Form Designer
    31.     'It can be modified using the Windows Form Designer.  
    32.     'Do not modify it using the code editor.
    33.     Friend WithEvents Button1 As System.Windows.Forms.Button
    34.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    35.         Me.Button1 = New System.Windows.Forms.Button
    36.         Me.SuspendLayout()
    37.         '
    38.         'Button1
    39.         '
    40.         Me.Button1.Location = New System.Drawing.Point(172, 80)
    41.         Me.Button1.Name = "Button1"
    42.         Me.Button1.Size = New System.Drawing.Size(92, 23)
    43.         Me.Button1.TabIndex = 0
    44.         Me.Button1.Text = "Enumerate Me"
    45.         '
    46.         'Form1
    47.         '
    48.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    49.         Me.ClientSize = New System.Drawing.Size(292, 126)
    50.         Me.Controls.Add(Me.Button1)
    51.         Me.Name = "Form1"
    52.         Me.Text = "Running Processes Using WMI"
    53.         Me.ResumeLayout(False)
    54.     End Sub
    55. #End Region
    56.  
    57.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    58.         Dim search As New ManagementObjectSearcher("SELECT * FROM Win32_process")
    59.         Dim info As ManagementObject
    60.         For Each info In search.Get()
    61.             MessageBox.Show(info.GetText(TextFormat.Mof).ToString, "Running Processes Information", _
    62.             MessageBoxButtons.OK, MessageBoxIcon.Information)
    63.         Next
    64.     End Sub
    65. End Class
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by RobDog888; Jul 1st, 2005 at 04:41 PM. Reason: Forgot the zip file. :D
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Enumerate Running Processes With X-Treme Details Using WMI :D

    Excellent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width