Link to home
Start Free TrialLog in
Avatar of nibby
nibby

asked on

closing outlook using a batch file? or other method?

Hi, I'm looking to do the following:

I have a number of PC's that I would like to create a backup of their .pst file - I can do this by creating a batch file pointing at the .pst file and saving to another location but want to make sure that outlook is closed first. Is there a way of doing this either in the batch file or another method?
If you know of any other more successful way I would also be interested.
many thanks
Avatar of Jay_Jay70
Jay_Jay70
Flag of Australia image

Hi nibby,

we do ours via a logon script - if it hasnt been backed up within a few days the use gets prompted to back it up by running a backup script, you could always use robocopy to force a backup when the user logs off windows

Cheers!
Avatar of nibby
nibby

ASKER

Thanks, where will I find robocopy and is it difficult to use/setup?
Ideally looking for example for say one pc if possible?
Cheers
robocopy is easy as to use and is built into windows

http://www.ss64.com/nt/robocopy.html

im not allowed to give out our script at the moment due to the fact that i didnt write it, if you can script at all, robocopy will make life much easier for you

once you figure out the syntax you want, add it to a vbs file, and set as a log off script
Avatar of nibby

ASKER

many thanks, fully understand.

anyone else have a script they can give me?
nibby,

sorry that i cant give out the script, i am learning a bit of scripting at the moment though, so if you can get a direct script given to you, send me an email and ill see what i can for you yeah?
Avatar of Danny Child
I'd also consider getting the relevant PC to shut down (if the PST files are on a network drive), or Reboot (if they're on C:)

The reason for this is that I've seen PST files be still flagged as open, when outlook is closed, and also sometimes there's a "rogue" Outlook process running even when there's no sign of Outlook on the task bar.  Often linked to folks who use PDAs and ActiveSync etc.

To force a shutdown or restart, there's shutdown.exe from the Resource Kit, but I think PSShutdown is more reliable:
http://www.sysinternals.com/Utilities/PsShutdown.html
The users can get warnings or the ability to cancel, and it also gives options to run additional commands (like your backup command???)

I've used this in scripts that are invoked when UPS units are running, to safely shut down servers and pcs before the UPS batteries run out.  
hth
Danny
Save this to batch file ..

------------------------------------------------------

echo off
echo      ** Ending MS-OutLook, Press any key to continue
pause
C:
cd\
cd C:\Program Files\Microsoft Office\OFFICE11
taskkill /im outlook.exe
exit

-------------------------------------------------------
Avatar of nibby

ASKER

moh10ly,
many thanks this is perfect for what I'm looking for. One final question can you tell me what to add to tell the batch file that "if outlook is already closed then that is fine and to carry on with the next command" at the moment I'm getting the following message "Error, the process "outlook.exe was not found"

Thanks again.
Are you using two commands at the same batch ??
If so then you should remove the exit command so the batch file can carry on with the next command that you want to add,, note that you have to add CLS command to clear the screen..

Or use "Exit /b" This will exit the current batch script instead of CMD.EXE

Or you can use the IF function for such thing... For information about using the IF function see some examples here..
http://www.robvanderwoude.com/index.html
Avatar of nibby

ASKER

I have this, what would I add after the taskkill /im outlook.exe (the xcopy is just an example and not the full command) what is happening is that if outlook is not open then it wont carry out the copy command, if outlook is open then it is fine.

Cheers


echo off
echo      ** Ending MS-OutLook, Press any key to continue
C:
cd\
cd C:\Program Files\Microsoft Office\OFFICE11
taskkill /im outlook.exe
xcopy "C:\Documents and Settings
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Hamada
Mohammed Hamada
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nibby

ASKER

Thanks, it worked fine this time around. Points on their way.