Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch file to detect running program

Posted on 2011-02-23
3
Medium Priority
?
744 Views
Last Modified: 2012-05-11
Hi All,

I have a app which was written by a developer who has since lft our company. From time to time, the app decides to stop working and close without error or warning.

I was think that it might be possible to have a batch file which runs on an hourly basis which checks to see if the app is still running, if not send an alert. Ive already got the alert process sorted by using something called BLAT which is a simly little utlility which when called, sends an email to a distribution list on our exchange server.

Has anyone got a simply batch file which can check to see if a process/application is running and then call my BLAT process?

I can confirm the app is listed in the Task List and within the Applications Running Tab of the Task Manager.

Thanks
DW
0
Comment
Question by:daiwhyte
[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 3

Assisted Solution

by:OrenRozen
OrenRozen earned 1000 total points
ID: 34960643
create a batch file named lookfor.cmd (or what you'd like) using the following code

to run it : lookfor OUTLOOK.EXE

NOTE: make sure the application have the exact name as shown in tasklist

@echo off

:again
echo looking..
for /F "tokens=1" %%a in ('tasklist ^| find /I "%1"') DO if "%%a"=="%1" goto Yes
echo app not runningn
goto :end

:Yes
echo app running

:end

Open in new window

0
 
LVL 57

Accepted Solution

by:
Bill Prew earned 1000 total points
ID: 34966612
Give this a try as your BAT file thatyou schedule.

@echo off
set Image=imagename.exe
set Found=N
tasklist /fi "imagename eq %Image%" | find /i "%Image%" >NUL && set Found=Y
if "%Found%" EQU "N" (
  REM Do email logic here
)

Open in new window

~bp
0
 

Author Closing Comment

by:daiwhyte
ID: 34969046
Thank you both.
0

Featured Post

Industry Leaders: 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 quick step-by-step overview of installing and configuring Carbonite Server Backup.
Learn about cloud computing and its benefits for small business owners.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 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