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

x
?
Solved

Batch file to detect running program

Posted on 2011-02-23
3
Medium Priority
?
746 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 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 59

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
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. …

916 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