Re: How to prevent task scheduler from starting a program already running

Tech-Archive recommends: Fix windows errors by optimizing your registry



I tried saving the file in 3 different ways (separately of course)
1) "c:\desktop\outlook.bat"
2) "c:\Windows\LaunchOutlook.bat"
3) "c:\programs\microsoft office\office11\outlook.bat"

Here is what happened:
1) If the program is already running...another instance is not started
2) If the program is not running....it does not start

so the bottom line is...this did not work, unfortunately. I should mention
that at the specified time a small black screen comes up for a few seconds
and disappears. Seems like we have the right idea that needs further
development

I await your responses

Nick

"Pegasus (MVP)" <I.can@xxxxxxx> wrote in message
news:%23nerJ6UzGHA.3748@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for expanding my suggestion. There is actually
something I need to add. You recommended to the
OP to save the batch file as "Outlook.bat". This is a
bad idea and it frequently pops up in these newsgroups.
You must never create a batch file under the same name
as an executable. At best you will get a looping batch
file and at worst some totally confusing behaviour. Call
it "c:\Windows\LaunchOutlook.bat" instead.


"Peter Howarth" <PHowarth@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:RIFJg.3370$Z_5.1565@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

Pegasus's message, in simple terms:

1) Start notepad (start -> programs -> accessories -> notepad)
2) copy the two lines below (which pegasus provided, except I've filled
them
in a bit), into notepad:

@echo off
TaskList | find /i "Outlook" || "c:\Program files\microsoft
office\office10\outlook.exe"

3) In task scheduler, edit the current task (right-click, properties) and
look at the text in the 'run' box - it will look something like the last
half of the line we just copied into notepad. If it is different, then
copy
and paste it from the run box into the notepad file. (If you have a
different version of Office to me, it will certainly be different)
4) save the file somewhere as outlook.bat (ensure you select 'All files'
in
the 'files of type' option in the save dialog, or your file will be
"outlook.bat.txt" which we don't want)
5) Back in task scheduler, click the browse button and locate the
outlook.bat file you just created.

That should work. (Pegasus, feel free to correct anything if I've missed
something)

Basically, the batch file (outlook.bat) gets a list of currently running
processes (tasklist) and passes it onto the 'find' command which searches
for 'outlook' in that list. If it finds it, then the batch file stops
(because outlook is already running). Otherwise it runs Outlook.

Peter


"Nick Cumberbatch" <nickcwpg@xxxxxxxxxxx> wrote in message
news:um3wFBRzGHA.5072@xxxxxxxxxxxxxxxxxxxxxxx
I should have mentioned that my computer knowledge just a little more
than
beginner.

Could you kindly interpret this for me in simple instructions

Thanks

"Pegasus (MVP)" <I.can@xxxxxxx> wrote in message
news:uSklzmQzGHA.3908@xxxxxxxxxxxxxxxxxxxxxxx

"Nick Cumberbatch" <nickcwpg@xxxxxxxxxxx> wrote in message
news:%23kmJlRQzGHA.3908@xxxxxxxxxxxxxxxxxxxxxxx
I am using Windows XP Professional.

I have setup Task Scheduler to start Microsoft Outlook to run at 7 AM
each
day. However since I use the program often, I may sometimes leave it
running overnight. Then in the morning I find two instances of
Microsoft
Outlook running, the one that I started originally and the one Task
Scheduler started. How do I resolve this




Embed Outlook in a batch file like so:

@echo off
TaskList | find /i "Outlook" || c:\Program . . . . \ outlook.exe










.


Quantcast