Taskkill

I need a coomand line script to see if jqs.exe is running and if it is do taskkill /f /im jqs.exe
LVL 1
underground712Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ZoppoConnect With a Mentor Commented:
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
 
Bill PrewCommented:
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
 
ZoppoCommented:
Sorry, of course the notepad.exe is wrong in lines 2 and 3, I used this for testing - replace it with jqs.exe
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
Bill PrewCommented:
Ditto for replacing "foo.bar" with "jqs.exe"...

~bp
0
 
underground712Author Commented:
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
 
Bill PrewCommented:
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
All Courses

From novice to tech pro — start learning today.