robkarlen
asked on
How do I terminate a process based on application name instead of process name in vbs?
I'm looking for the correct syntax in vbs to kill a process based on it's application name in task manager. My current code kills the process based on it's process name, but the problem now is that it kills all running iexplore processes whereas they require it to just kill one specific instance.
KillApps = "iexplore.exe, Please Wait.exe"
For Each app In Split(KillApps, ", ")
Set objProcs=GetObject("winmgmts:\\.\root\cimv2").ExecQuery("select * from Win32_Process where Name='" & app & "'")
For Each process In objProcs
process.Terminate
Next
Next
WScript.Quit
It is possible, but it requires that Microsoft Word is installed:
How Can I Close a Command Window with a Specific Title?
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov05/hey1130.mspx
Regards,
Rob.
How Can I Close a Command Window with a Specific Title?
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov05/hey1130.mspx
Regards,
Rob.
ASKER
That's so very close to what I need but unfortunately not all of our machines have Word. Can you create an object of word viewer and accomplish this by any chance? - it doesn't appear to be a builtin server class Licensing restrictions do not allow us to have Word on every machine.
Thanks for the help so far, you've got me pointed in a good direction.
Thanks for the help so far, you've got me pointed in a good direction.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a bunch. A little tweaking got me exactly what I needed. I would have never ever thought of this approach so thank you so very much.
Thanks for the grade.
Was the tweaking anything major? This appeared to work for me OK....
Regards,
Rob.
Was the tweaking anything major? This appeared to work for me OK....
Regards,
Rob.
ASKER