I am trying to close multiple applications at the same time using the following VBS script, but am getting the error 0x80041017 on the For Each loop line. It works fine with just one application but I added another to terminate
strComputer = "."
strProcessToKill1 = "Acrobat.exe" 
strProcessToKill2 = "iexplore.exe" 
Set objWMIService = GetObject("winmgmts:" _
                & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colProcess = objWMIService.ExecQuery _
                ("Select * from Win32_Process Where Name = '" & strProcessToKill1 & "' or '" & strProcessToKill2 & "'")
count = 0
For Each objProcess in colProcess
                objProcess.Terminate()
                count = count + 1
Next 
Your WMI query is invalid, which is causing the loop to fail.  You need to specify the column (Name) for the second half of the WHERE clause.  I would also remove the brackets for the objProcess.Terminate call as well.  
strComputer = "."
strProcessToKill1 = "Acrobat.exe" 
strProcessToKill2 = "iexplore.exe" 
Set objWMIService = GetObject("winmgmts:" _
                & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colProcess = objWMIService.ExecQuery _
                ("Select * from Win32_Process Where Name = '" & strProcessToKill1 & "' OR Name = '" & strProcessToKill2 & "'")
count = 0
For Each objProcess in colProcess
                objProcess.Terminate
                count = count + 1
Next 
User contributions licensed under CC BY-SA 3.0