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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e_aravindCommented:
can you kill the javaw.exe from the task-manager?
is that going-out of the process list or re-appearing again?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.