1.

Solve : Need Advice with this Backup Script?

Answer»

Below is an Outlook backup script I have compiled through much searching and trial and error. This script will close Outlook on a networked client computer where the user is still logged on; then backup his/her Outlook .pst files to a shared user folder on a Win 2003 server. After the backup is done the script will RESTART Outlook minimized to the system tray. Some users Outlook needs to be restarted so a third party "Out of Office" application can run.

This works for my users that have Outlook already open and then need it to be reopened for the reason stated above. However, for the users who do not have Outlook open and don't need it to be reopened this script (even though it does backup their Outlook files) is lacking and needs some tweaking.

What I would like it to do (but don't know how to do it) is to use some kind of statement that will do the following:

Check first to see if the users Outlook is open
If it is then taskkill / IM outlook.exe - and run %backupcmd%
If it is not open then just run %backupcmd%

After the .pst files are saved back to the server, then reopen Outlook on the users that had Outlook open in the first place and/or leave Outlook closed on the users that never had it open to begin with.

The way the script stands now it does work but if a user does not have Outlook opened then an error occurs - ERROR: The process "outlook.exe" was not found - but the script still runs and completes. Also the users that did not have Outlook opened now do after the script has finished

I will be putting this script on each users computer and then using XP's scheduler to schedule the backups. My knowledge of scripting as you've no doubt guessed is next to none, so this is the only way that I know how to do it. I am open to SUGGESTIONS and help. Thank you in advance
Below is the script thus far.
--------------------------------------------------------------
@echo off
:: variables
set drive=\\Droopy\user_emails$\bbking
set backupcmd=xcopy /s /c /d /e /h /i /R /y

echo Closing Outlook...
taskkill /IM outlook.exe
echo.
echo Pausing...
ping 1.1.1.1 -n 3 -w 1000 >nul
echo.
echo Backing up Outlook Files...
echo.
%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"
echo.
echo Backup Complete!
echo.
echo Restarting Outlook...
@echo off
start /d /MIN "C:\Program Files\Microsoft Office\OFFICE11" OUTLOOK.EXE
------------------------------------------------------------

Thanks Again.
DougOne way would be to iterate thru all the running processes.

Code: [Select]@echo off
:: variables
set drive=\\Droopy\user_emails$\bbking
set backupcmd=xcopy /s /c /d /e /h /i /r /y

echo Closing Outlook...

for /f "tokens=2" %%i in ('tlist') do (
if /i %%i==outlook.exe taskkill /IM outlook.exe
)

echo Pausing...
ping 1.1.1.1 -n 3 -w 1000 >nul
echo.
echo Backing up Outlook Files...
echo.
%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"
echo.
echo Backup Complete!
echo.
echo Restarting Outlook...
@echo off
start /d /MIN "C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE"

Depending on which version of XP (Home or Pro) you have, you may have to use tasklist instead of tlist. In that CASE change tokens=2 to tokens=1.

Good luck.

PS. I also changed the start command. For some reason, yours LOOKED too funky to be correct.Thanks Sidewinder. This will work. I know that there is probably an easier way to do this but so far we don't have to many clients on our network so this will work. We have all XP Pro so I changed to tasklist and tokens=1. As for the start line I first tried it the way you have it (i.e. quotes around the whole path) and got a Path not found error (something like that). Did some digging on line and tried the way I currently showed in the first post and that worked! Not sure why, though.

Thanks again.
Doug



Discussion

No Comment Found