Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon





© winscripter.com
1998-2004







Script: List All the Processes Running on a PC

Posted by on Monday, January 19, 2004 (PST)

Script: Using WMI, lists all the processes currently running on a machine. Displaying their Name and Handle. Uses WMI Win32_Process.

 

// Get Object and create enumerator 
var e = new Enumerator( GetObject( "winmgmts:" ).InstancesOf( "Win32_process" ) );
// Variable to hold the info we find 
var msg = "Processes\n";
// Loop through processes 
for (;!e.atEnd();e.moveNext())
{
    // Get object from enumerator
    var p = e.item ();
 
    // Format message with process name and handle
    msg += p.Name + " [" + p.Handle + "]\n";
}
// Display the results 
WScript.Echo( msg );

Add Your Comment



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon