Solved

Batch file to detect running program

Posted on 2011-02-23
3
711 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
3 Comments
 
LVL 3

Assisted Solution

by:OrenRozen
OrenRozen earned 250 total points
Comment Utility
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 51

Accepted Solution

by:
Bill Prew earned 250 total points
Comment Utility
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
Comment Utility
Thank you both.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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 explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

11 Experts available now in Live!

Get 1:1 Help Now