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

x
?
Solved

Taskkill

Posted on 2011-03-04
6
Medium Priority
?
1,003 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 59

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 500 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 59

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 59

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

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