• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

VBScript to close program

Hi all,

I need to run a vbscript to close an application that I have running. I am planning on calling this vbscript from a scheduled task.
For some reason the taskkill wouldn't work for me in a batch file and so I'm looking now at vbscript as a solution. I am using Wndows 2008 R2.

Thanks in advance for your help.
1 Solution
try this:

Set objShell = CreateObject("WScript.Shell")
Set objWmi = GetObject("winmgmts:")

strWmiq = "select * from Win32_Process where name='iexplorer.exe'"
Set objQResult = objWmi.Execquery(strWmiq)

For Each objProcess In objQResult
intRet = objProcess.Terminate(1)

Open in new window

I haven't tried it myself
oconnork00Author Commented:
That works perfectly, thank you.
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.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now