Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to make batch file execute as a singleton?  (Read 4292 times)

0 Members and 1 Guest are viewing this topic.

musookia

  • Guest
How to make batch file execute as a singleton?
« on: February 06, 2009, 03:43:07 AM »
Hi,

I have a Talend (ETL software) job  that is launched using a BAT File every day at 01:00 a.m. This batch should be able to be run manually. But on manual run, if it is already running, I have to display an error message to the Administrator and prevent him from running it. Typical singleton requirement.
Can someone please help me out with how to do this on DOS ?

Dias de verano

  • Guest
Re: How to make batch file execute as a singleton?
« Reply #1 on: February 06, 2009, 04:10:46 AM »
if you set the window title in the batch e.g.

Code: [Select]
title MyTitle
you can use tasklist with the /v (verbose) switch to find if a window with that title is already running

Code: [Select]
title NotMyTitle
tasklist /v | find "MyTitle">nul && goto skip
title MyTitle

[i]your code[/i]

goto end

:skip
echo Batch file is already running!
Pause
:end
exit

« Last Edit: February 06, 2009, 04:52:11 AM by Dias de verano »