![]()
Update: This has been tested in Outlook 2010, 2007 & 2003
I find that Outlook’s Personal Folder (.pst) files have a haphazard way of getting corrupted – which obviously impacts daily performance as well as reliability of my email achieve. Microsoft’s Inbox Repair Tool (ScanPST) diagnoses and repairs corrupt .pst/.ost files to make sure the file structure is intact, but the process requires more manual intervention than I care for. So, here’s how I made Outlook’s Inbox Repair process completely automated:
Step 1: Download some 3rd party utilities!
- Download NirCmd.zip.
In order to run the ScanPST utility against your .pst/.ost files, Outlook must be shutdown. While there isn’t a way to do what we need natively in Windows, NirCmd (free) allows us to accomplish the task gracefully – meaning Outlook will not shut down when unsaved content exists (in which case the Repair will be skipped for this instance).
(Note: If you prefer to forcefully end Outlook, you can do so using process.exe 1 . Of course, doing this could cause corruption – which is what we’re trying to avoid/fix!) - Extract nircmdc.exe2 to ‘C:\\Windows\System32′.
(Note: I don’t usually like to install 3rd party executables to WindowsSystem32. In this case, however, I feel these simple cli utilities don’t justify additions to my Path entry. If you wish to install somewhere else, you can add the location to your Path3 or add the full path into the script file.) - Download cmdscan.zip.
Quester’s cmdscan (free) allows us to run ScanPST without any user interaction. - Extract cmdscan.exe to ‘C:\\Windows\System32′
- Download autopst.bat – my batch file template.
The next Steps will outline what is happening in the batch file:
Step 2: Make sure Outlook is not running/Close Outlook if it is.
- (informational) To gracefully close outlook, the script executes:
nircmdc closeprocess outlook.exe.
To test your nircmd install, open Outlook and execute this command from the command prompt. - (informational) We want to wait for Outlook to close because the Repair Tool will not analyze/fix an open .pst file. To do this, the script executes:
nircmdc waitprocess outlook.exe.
Step 3: Run ScanPST from the Command Line.
- Find the path to scanpst.exe on your computer:
- in Outlook 2003 – C:\\Program Files\Common Files\System\Mapi\1033\
- in Outlook 2007 – C:\Program Files\Microsoft Office\Office12\
- Edit autopst.bat in notepad and verify ScanPST-location=”<your path>”
- If your .pst/.ost files are in the default location, the command in the script – cmdscan %ScanPST-location% *.pst *.ost – will work just fine. (Otherwise, follow the instructions in readme.txt, found in the cmdscan.zip file. It will show all your file selection options).
Step 4: (optional) Open Outlook so it’s ready to go when you access your computer again.
- If you prefer to automatically restart Outlook after the scan, remove “REM” from the front of the “REM start outlook.exe” line.
Step 5: Create a Scheduled Task 4
- Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks.
- Next -> Browse… -> select the autopst.bat file -> Next
- Select task frequency (i.e., Daily/Weekly) -> Next
- Set run time (when are you least likely to need Outlook open?
- …you get the idea…
Step 6: Test
- Double-click on the autopst.bat file or execute the newly created task to make sure things go as expected.
- Command Line Process Viewer/Killer/Suspender – This method first tried to gracefully shut down Outlook. If Outlook remains open after 60 seconds, the process is forced to terminate. [↩]
- nircmdc is a command line only version of nircmd – this makes popup dialogs print to cmd window instead; thus, allowing us to automate processes more reliably [↩]
- How to set the path in: Windows XP / Vista [↩]
- How To Schedule Tasks in Windows XP [↩]
September 2, 2008
Tags: 
