View Single Post
  #2 (permalink)  
Old October 8th, 2004, 01:12 PM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If the page is running in a low security zone, Local intranet or Trusted sites it is provided that WMI is operational (most modern Windows systems).
Code:
<html>
<head>
<title>Processes</title>
<script type="text/jscript">
function getProcessList()
{
  var procs = GetObject("WinMgmts:").InstancesOf("Win32_Process");
  var mainRes = "";
  procEnum = new Enumerator(procs);
  for ( ; !procEnum.atEnd(); procEnum.moveNext())
  {
    var proc = procEnum.item();   
    mainRes += proc.Name + ": " + proc.ProcessID + "\n";
  } 
  return mainRes;
}

function showProcesses()
{
  var oOutput = document.getElementById("txtProcesses");
  oOutput.value = "";
  oOutput.value = getProcessList();
}

</script>
</head>

<body bgcolor="#FFFFFF">
<input type="button" value="Show Processes" onclick="showProcesses();"><br>
<textarea id="txtProcesses" cols="30" rows="40"></textarea>
</body>
</html>
--

Joe
Reply With Quote