Recipe 6.4. Viewing the Running ProcessesProblemYou want to see all processes that are currently running on a system. SolutionUsing a graphical user interface
You can also accomplish the same task using the Sysinternals Process Explorer (procexp.exe) tool. Using a command-line interfaceThere are several options for viewing the running processes via the command line. You can use tasklist.exe on Windows XP and Windows Server 2003 (use the /S option to target a remote system): > tasklist Another Windows XP and Windows Server 2003 tool that you can use to get a process list is wmic as shown here (use the /node: option to target a remote system): > wmic process list brief The Sysinternals pslist.exe utility is available for Windows Server 2003 or Windows 2000 and can be run against a remote host: > pslist \\<ServerName> There is also the top.exe command, which is available in the Windows 2000 Resource Kit. It provides a continually updated view of the top running process (by CPU): > top
Using VBScript' This code displays the running processes on the target computer. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." ' Can be a hostname or "." to target local host ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colProcesses = objWMI.InstancesOf("Win32_Process") for each objProcess In colProcesses WScript.Echo objProcess.Name & " (" & objProcess.ProcessID & ")" next DiscussionSometimes it is difficult to associate an application (e.g., Internet Explorer) with its underlying process (e.g., iexplore.exe). In each of the command-line solutions, only the process name will be shown, which may be completely different from the name of the application. With Internet Explorer, it is pretty easy to figure out that iexplore.exe is probably the underlying process, but how can you tell for sure? One way is to look at Sysinternals Process Explorer. It displays a Description field that generally contains the application name of the process. Alternatively, you can specify the /v option with the tasklist command, which displays the Window Title field for each process. This typically includes the name of the application. Here is an example command you can run: > tasklist /v /fo list Unfortunately, there you can't retrieve the Window Title using the Win32_Process class. |