Computing.Net > Forums > Programming > Loop til outlook.exe is not running

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Loop til outlook.exe is not running

Reply to Message Icon

Name: AJ (by William Jimenez)
Date: October 21, 2008 at 07:56:47 Pacific
OS: windows XP
CPU/Ram: Dell
Comment:

Hello,

I wrote a small batch that amongst other things checks if MS Outlook is running, if so closes outlook and backs up the pst files then restarts outlook.

I do this using PV.exe then checking the errorlevel output and if it is 1 (not running) I start the backup, otherwise the taskkill /IM outlook.exe terminates outlook.

pv > C:\result.txt

findstr /I "OUTLOOK" C:\result.txt
if ERRORLEVEL 1 GOTO START


My problem is that this only runs once and as we all know users sometimes will start multiple instances of Outlook.exe

I'm by no means a programmer so take it easy on me, I've been trying unsuccessfully to write a loop that will cicle through the above code until error level =1 (not running) but I have failed miserably.

HELP!

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: October 21, 2008 at 09:24:06 Pacific
Reply:

:LOOP
pv | find /I "outlok.exe" > Nul || goto :START
taskkill /IM outlook.exe
goto :LOOP

:START


0

Response Number 2
Name: amlife
Date: October 21, 2008 at 11:48:20 Pacific
Reply:

you don't have lable called "start" and your
GOTO command pointing to no where.

:START
pv > C:\result.txt
findstr /I "OUTLOOK" C:\result.txt
if ERRORLEVEL 1 GOTO START


0

Response Number 3
Name: IVO
Date: October 21, 2008 at 12:25:21 Pacific
Reply:

amlife,

you posted an endless loop!

Reread the original question and think about...


0

Response Number 4
Name: AJ (by William Jimenez)
Date: October 22, 2008 at 07:51:12 Pacific
Reply:

Thank you all for your ideas. I wanted to let you know that i actually found a very easy way to do it. PV.exe has two switches that allows me to do this.

-k kill process
-k outlook* will kill one of anything starting with the word outlook

-r[errorlevel] will continue looping until errorlevel=1 or 0 (1=yes 0=no)

-f will suppress asking for confirmation.

So my problem was solved by this simple line

pv -k outlook* -r1 -f

Thank you all once again this is a great board. I've found more answers here than anywhere else on the net. My hat is off to you all.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Loop til outlook.exe is not running

Know when a program is done running www.computing.net/answers/programming/know-when-a-program-is-done-running/10364.html

C++ 3.0 is not working over XP OS www.computing.net/answers/programming/c-30-is-not-working-over-xp-os/13290.html

VB 6 Program www.computing.net/answers/programming/vb-6-program/14201.html