Solved

Taskkill

Posted on 2011-03-04
6
949 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 52

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 52

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now