Solved

Taskkill

Posted on 2011-03-04
6
965 Views
Last Modified: 2012-05-11
I need a coomand line script to see if jqs.exe is running and if it is do taskkill /f /im jqs.exe
0
Comment
Question by:underground712
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Bill Prew
ID: 35037411
Why bother checking if it's running just to kill it.  Do the killtask all the time and if it isn't running it will just fail to kill anything.  If you want to suppress the error message from killtask then you can do:

taskkill /f /im foo.bar >nul 2>%1

~bp
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 125 total points
ID: 35037462
Hi underground712,

I agree with billprew, there's no need to check if the process is running.

Anyway, if you really want to check it before you can use this in a batch file:

@echo off
tasklist | findstr "notepad.exe" > nul
if %ERRORLEVEL%==0 taskkill /f /im notepad.exe

Open in new window


ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 35037469
Sorry, of course the notepad.exe is wrong in lines 2 and 3, I used this for testing - replace it with jqs.exe
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 53

Expert Comment

by:Bill Prew
ID: 35037502
Ditto for replacing "foo.bar" with "jqs.exe"...

~bp
0
 
LVL 1

Author Comment

by:underground712
ID: 35037523
it has to be checked, cause just the taskkill is running from zcm10, and script engine reports to the user when installing the application
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 35037648
And we can simplify a little more to get it down to a single line like this:

tasklist /FI "IMAGENAME eq jqs.exe" 2>NUL | find /I "jqs.exe" >NUL && taskkill /F /IN jqs.exe

Open in new window

~bp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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