I wanted to kill the cmd.exe process by clicking the stop button through VB script. Its not working.
The subroutine works fine if i run it separately as a .vbs file.
i even tried by keeping the subroutine code in a separate .vbs file & calling it in my html file.
<html>
<head>
<SCRIPT LANGUAGE="VBScript">
Sub stopbtn_OnClick
MsgBox "Mirabile visu."
strComputer = "."
strProcessToKill = "cmd.exe"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")
count = 0
For Each objProcess in colProcess
objProcess.Terminate()
count = count + 1
Next
wscript.echo "Killed " & count & " instances of " & _
strProcessToKill & "on " & strComputer
End Sub
</SCRIPT>
</head>
<body>
<form name="stoprc">
<tr>
<td width="80"></td>
<td><input type="button" value="Stop" name="stopbtn" ></td>
</tr>
</form>
<body>
</html>