|
|
|
Process Killer 3.2.0.0
2/19/2005
|
|
Download (35 KB) |
Background
Sometimes I have many applications of the same type opened. And sometimes I want to kill all of them in a single click. This utility was aimed at that purpose: having the possibility to "find" opened apps using a text search criteria and shutdown all matching processes with a single click. Utility reside in system tray, so being always available.
Implementation
Process list can be retrieved from local machine and remote computers. Anyway, you
need to have administrative privileges on remote PCs to get their process list.
Job is done using WMI. This is the relevant code:
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.Call;
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
// We don't need to use credentials on local machine
if (!((strServer.CompareTo(".") != 0)
|| (String.Compare(strServer, System.Environment.MachineName,
true) != 0)))
{
options.Username = strUsername;
options.Password = strPassword;
}
ManagementScope ms = new ManagementScope(@"\\"
+ strServer + @"\root\CIMV2", options); ms.Connect();
SelectQuery myQuery = new SelectQuery("Win32_Process");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms, myQuery);
runningProcesses = query.Get();
When enumerating is complete, a RegEx is applied to seek desired processes.
Process objects are wrapped in custom objects, so the can be sorted implementing
IComparer.
Process list can be represented in a flat style or in a tree view. Tree shows process
hierarchy.
|
|
|
|
Get Skype and call me for free.
|
|