Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Code to Kill a windows process

Posted on 2010-11-08
3
Medium Priority
?
623 Views
Last Modified: 2013-12-03
I'm looking for code that I can just put into a simple .bat file that will kill a process.  I want to schedule it to run with windows scheduler.  Is there some command string I can put in there to kill ag.exe process?
0
Comment
Question by:Nathan Riley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
fridom earned 1000 total points
ID: 34085483
http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx

If in doubt visit Sysinternal sites. You find many very usefull tools there.

Regards
Friedrich
0
 
LVL 15

Assisted Solution

by:JBond2010
JBond2010 earned 1000 total points
ID: 34085486
Using VBScript

strComputer = "."
strOwner = "A111111"
strProcess = "'notepad.exe'"
 
' Connect to WMI service and Win32_Process filtering by name'
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colProcessbyName = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " _
    & strProcess)
 
' Get the process ID for the process started by the user in question'
For Each objProcess in colProcessbyName
    colProperties = objProcess.GetOwner(strUsername,strUserDomain)
    if strUsername = strOwner then
        strProcessID = objProcess.ProcessId
    end if
next
 
' We have the process ID for the app in question for the user, now we kill it'
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & strProcessID)
For Each objProcess in colProcess
    objProcess.Terminate()
Next
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 34085541
Thanks, actually ended up doing it like this:

taskkill /F /IM AG.exe
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

636 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