Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript to close program

Posted on 2013-02-02
2
Medium Priority
?
620 Views
Last Modified: 2013-02-02
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.
0
Comment
Question by:oconnork00
2 Comments
 
LVL 6

Accepted Solution

by:
nickinthooz earned 2000 total points
ID: 38846689
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)
Next 

Open in new window


I haven't tried it myself
0
 
LVL 2

Author Comment

by:oconnork00
ID: 38846822
That works perfectly, thank you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question