• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1275
  • Last Modified:

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
0
nibby
Asked:
nibby
  • 5
  • 3
  • 3
  • +2
1 Solution
 
Jay_Jay70Commented:
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!
0
 
nibbyAuthor Commented:
Thanks, where will I find robocopy and is it difficult to use/setup?
Ideally looking for example for say one pc if possible?
Cheers
0
 
Jay_Jay70Commented:
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
nibbyAuthor Commented:
many thanks, fully understand.

anyone else have a script they can give me?
0
 
Jay_Jay70Commented:
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?
0
 
WelkinMazeCommented:
0
 
Danny ChildIT ManagerCommented:
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
0
 
Mohammed HamadaSenior IT ConsultantCommented:
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

-------------------------------------------------------
0
 
nibbyAuthor Commented:
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.
0
 
Mohammed HamadaSenior IT ConsultantCommented:
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
0
 
nibbyAuthor Commented:
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
0
 
Mohammed HamadaSenior IT ConsultantCommented:
I have done that, and it works fine with me though Outlook.exe is not started and it gave me the same message like the one you had...

Here's the batch file I ran ...

@echo off
echo      ** Ending MS-OutLook...
pause
C:
cd\
cd C:\Program Files\Microsoft Office\OFFICE11
taskkill /im outlook.exe
pause
xcopy c:\temp d:\
pause

     ** Ending MS-OutLook...
Press any key to continue . . .
ERROR: The process "outlook.exe" not fou
Press any key to continue . . .

C:\temp\dark_shading_0_0_1200.dat
C:\temp\dark_shading_0_0_2400.dat
C:\temp\dark_shading_0_0_600.dat
C:\temp\dark_shading_2_0_1200.dat
C:\temp\dark_shading_2_0_2400.dat
C:\temp\dark_shading_2_0_600.dat
C:\temp\dark_shading_3_0_1200.dat
C:\temp\dark_shading_3_0_2400.dat
C:\temp\dark_shading_3_0_600.dat
C:\temp\hpgt46.dat
C:\temp\staticGain_0_0_1200.dat
C:\temp\staticGain_0_0_2400.dat
C:\temp\staticGain_0_0_600.dat
C:\temp\staticGain_2_0_1200.dat
C:\temp\staticGain_2_0_2400.dat
C:\temp\staticGain_2_0_600.dat
C:\temp\staticGain_3_0_1200.dat
C:\temp\staticGain_3_0_2400.dat
C:\temp\staticGain_3_0_600.dat
C:\temp\staticOffset_0_0_1200.dat
C:\temp\staticOffset_0_0_2400.dat
C:\temp\staticOffset_0_0_600.dat
C:\temp\staticOffset_2_0_1200.dat
C:\temp\staticOffset_2_0_2400.dat
C:\temp\staticOffset_2_0_600.dat
C:\temp\staticOffset_3_0_1200.dat
C:\temp\staticOffset_3_0_2400.dat
C:\temp\staticOffset_3_0_600.dat
C:\temp\white_shading_0_0_1200.dat
C:\temp\white_shading_0_0_2400.dat
C:\temp\white_shading_0_0_600.dat
C:\temp\white_shading_2_0_1200.dat
C:\temp\white_shading_2_0_2400.dat
C:\temp\white_shading_2_0_600.dat
C:\temp\white_shading_3_0_1200.dat
C:\temp\white_shading_3_0_2400.dat
C:\temp\white_shading_3_0_600.dat
37 File(s) copied
Press any key to continue . . .

Can you provide me the command that you want to apply within this batch file..?
0
 
nibbyAuthor Commented:
Thanks, it worked fine this time around. Points on their way.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now