Computer Hope

Microsoft => Microsoft DOS => Topic started by: Yaro67 on July 15, 2008, 09:51:05 AM

Title: Starting Outlook from a batch file
Post by: Yaro67 on July 15, 2008, 09:51:05 AM
SO I have a issue with Outlook.  Every so often it comes up with a error that says the administrator has made a change and you need to restart Outlook for it to take effect.  But as far as I can tell there has been no changes.  The problem is I can't access other email account I have been granted to after that until I restart. So I figured instead of wasting time doing research or reloading office or at the far reach my system which I know I need to do anyway I would write a batch file to kill outlook and reopen it.  Simple enough...

taskkill /IM Outlook.exe /f

"%ProgramFiles%\Microsoft Office\Office12\outlook.exe"

EXIT

That's the basic jist of it...

My questions is why does the command window hang open after it reopens outlook and does not continue on to the exit?  And does anyone know how to fix it so it will close or continue on to the exit?

Thanks
Title: Re: Starting Outlook from a batch file
Post by: Sidewinder on July 15, 2008, 01:51:28 PM
You'd be surprised how many examples of the start command are posted when it is not needed or even helpful. Finally a request comes along where a start will actually be the solution.

Code: [Select]
taskkill /IM Outlook.exe /f
start "" "%ProgramFiles%\Microsoft Office\Office12\outlook.exe"
EXIT

Without the start, the batch file is waiting for Outlook to terminate before the exit instruction is executed. The start command runs Outlook in separate process, so the batch file can continue on to the exit.

Good luck. 8)
Title: Re: Starting Outlook from a batch file
Post by: Yaro67 on July 16, 2008, 06:45:15 AM
Thanks that definitely remember the "start" command in the future!   ;D
Title: Re: Starting Outlook from a batch file
Post by: blastman on July 16, 2008, 06:50:18 AM
just to add...

if you close outlook by killing the process you might have to wait a few secounds before starting it again. In my experenice...

To get round this add "ping localhost > nul" after the kill and before the start to pause the script for a bit.

You might also find that outlook will do the "Checking personal folders for errors" at start up, and if you're like any of my users that will take a while as there PST files are huge!!

Hope it helps.
Title: Re: Starting Outlook from a batch file
Post by: Yaro67 on July 16, 2008, 08:35:36 AM
You mean like...

@ping 127.0.0.1 -n 5 -w 1000 > nul

I learned that one a while ago seeing as their is no sleep command in batch.

And as far as archives go we try and not let them get too unruly sense...
1. Microsoft does not support running a archive from a network resource and...
2. If it gets to big, say bigger then 2GB, then it starts really acting up.

Thanks for your help!   ;)