why this script works in case of iexplore, but this doesn't work in case of javaw.exe?

Following script is to kill the process.
i want to know the reason why this script works in case of iexplore, but this doesn't work in case of javaw.exe

1)processName = "iexplore.exe"
this script works fine and IE can finish by using this script.
However,
in case of
2)processName = "javaw.exe"
This script doesn't work and I can't terminate the process.

Please let me know the reason why I can't kill the javaw.exe ?


'Object creation
Set objLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer


'Specify the process to kill
processName = "javaw.exe"


'Display message to ask confirmation

strMsg = processName & "  is OK to be killed ?"
Set objShell   = WScript.CreateObject("WScript.Shell")
rc = objShell.Popup(strMsg, 10,, vbOkCancel)

If rc = vbCancel Then
      Wscript.echo "Cancelled to kill the process"
      Wscript.Quit
ElseIf rc = vbTimeOut Then
      Wscript.echo "Killing the process is cancelled"
      Wscript.Quit
ElseIf rc = vbOK Then
      Set colProcSet = objService.ExecQuery("Select * From Win32_Process Where Caption='" & processName & "'")
      For Each objProc In colProcSet
            objProc.Terminate
      Next
End If


'Kill the process
i = 10
Do
      strTmp = ""
      Set colProcSet = objService.ExecQuery("Select * From Win32_Process Where Caption='" & processName & "'")
      
      For Each objProc In colProcSet
            strTmp = objProc.Name
      Next
      
      If strTmp <> "" Then
            i = i - 1
            If i = 0 Then
                  Wscript.echo processName & "failed to kill the process."
                  Wscript.Quit
            End If
            Wscript.Sleep 500
      Else
            Exit Do
      End If
Loop

Wscript.echo processName & "end"
shouichiAsked:
Who is Participating?
 
e_aravindConnect With a Mentor Commented:
can you kill the javaw.exe from the task-manager?
is that going-out of the process list or re-appearing again?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.