Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

getting description from process Tab in Task Manager in windows 2008 64 R2

how can i get the description for a process since i have used the code below it does not give what is displayed in task manager


Dim objWMIService,colProcess, objProcess
objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Me.lstServers.SelectedItem.ToString & "\root\cimv2")
        colProcess = objWMIService.ExecQuery("SELECT * FROM Win32_Process")



For Each objProcess In colProcess
            Me.lstServices.Items.Add(objProcess.Description)
Next


It gives me most of the other information but not that one.

Thank You.
0
mphillip85
Asked:
mphillip85
1 Solution
 
ApothisCommented:
Use powershell instead:
get-process | select name,description

Open in new window

To see everything you can query:
get-process | select *

Open in new window

0
 
mphillip85Author Commented:
i need this to be in vb.net or vb.script code

thank you
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
ltlbearand3Commented:
since you mention vb.net and it appears that is what you are really coding in you can use the Process.GetProcess function.  The one warning here is that you can run into Access denied errors on some of the restricted items and need to account for that in code.  You can adjust your code snippet using the concepts here:

For Each processitem As Process In Process.GetProcesses
	Try
		Dim strDescription As String = processitem.MainModule.FileVersionInfo.FileDescription
		Me.lstServices.Items.Add(strDescription)
	Catch exWin32 As System.ComponentModel.Win32Exception
		Debug.Print("Access was Denied How Do you want to handle that?")
	Catch ex As Exception
		Debug.Print("Other Errors")
	End Try
Next

Open in new window


-Bear
0
 
mphillip85Author Commented:
thank you i will try this and see what happens.
0
 
ApothisCommented:
I only recommend Powershell because you can still code VB within it, but you can get the features of Powershell as well.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now