Yes, you can! The following approach targets only MSIE and may raise security warnings.
When executed under MSIE, the following code lists all Windows processes in the browser window and shows a javascript alert if McAfee is running:
<html>
<body>
<div id="list"></div>
</body>
<script>
// create a shell object and exec handle
var shell = new ActiveXObject('WScript.Shell');
var handle = shell.Exec("tasklist.exe");
// loop through the output of tasklist.exe
while (!handle.StdOut.AtEndOfStream) {
// grab a line of text
var p = handle.StdOut.ReadLine();
document.getElementById("list").innerHTML+=p+"<br>"; // for debugging
// split on space
p = p.split(' ');
if (p[0]=='mcshield.exe') {
alert("McAfee detected");
}
} // end :: while
// clean up
handle = null;
shell=null;
</script>
</html>
Credit: inspired by https://stackoverflow.com/a/6834585/698168
This code was tested under the following browsers:
- MSIE 8.0.6001.18702 / Windows XP Pro
- MSIE 10.0.9200.16521 / Windows 7 ; Standard document mode
- MSIE 11.0.9600.16428 / Windows 7 ; Edge (aka MSIE11) document mode
If you got a JavaScript error Automation server can't create object
when creating the ActiveXObject
, you may need to set MSIE's Security option Initialize and script ActiveX controls not marked as safe for scripting
to either Prompt
or Enable
.
Under Firefox, you should use something based on XPCOM's nsIProcess.
Note that tasklist.exe
is not available under all Windows version: AFAIK it's available since Windows XP Pro.