CSCANPST - A command line interface for the SCANPST

Overview

SCANPST is a utility published by Microsoft for repairing Outlook PST files. Unfortunately, the SCANPST utility does not have any command-line interface so you can only control it interactively from the GUI. Since SCANPST can take a long time to run and because it requires user input while running, this can be a big waste of time.

CSCANPST is tool that will let you use SCANPST from the command-line, making it possible to write batch files that will run SCANPST unattended.

Why would you want to run SCANPST from the command-line?

To save time. Even if you only have a single PST file, every time you run SCANPST you have to sit and watch it run so you can respond to the pop-up dialog boxes that it generates. By contrast, with CSCANPST, you can start the process and then go get a cup off coffee; it will run until it is done without needing any additional input from you.

If you have multiple PST files, you can even use a batch file to automatically run SCANPST on all of them with just one step. Again, you can start the process and then let it run until it is done while you do something else. This is much better than having to manually launch SCANPST on each PST file individually and watch it run.

Quick Start

  1.  Click here to download CSCANPST.ZIP and unzip it to your hard drive.
  2. Open the SCANALL.BAT file using Notepad or any text editor.
  3. Change the SCANPST_PATH line to point to the location of your local copy of SCANPST.EXE.
  4. Change the PST_FILE_MASK line to point to the directory where you keep your Outlook PST files.
  5. Save and close the SCANALL.BAT file.
  6. Run SCANALL.BAT either from a command prompt or by double clicking on it.

Usage

The CSCANPST.EXE executable takes two parameters. The first is the fully qualified path to a SCANPST.EXE executable. The second is the name of the PST file to scan.

Once launched, CSCANPST will load SCANPST and send it the requested filename. It will respond to SCANPST input requests until either the file is repaired or there is an error.

On exit, CSCANPST will set the DOS errorcode to one of the following values...

ErrorLevel Meaning
0 Scan completed successfully. Any errors in the PST file were repaired.
1 Another copy of SCANPST is already running. Quit out any running instances and try again.
2 User canceled the scan.
3 Error opening the specified PST file.
4 File already in use. Make sure Outlook is not running.
5 Could not find the specified PST file. Check that you specified the correct directory and filename.
6 File type not recognized. Make sure the specified file is an Outlook PST file.


CSCANPST will always answer "yes" when SCANPST asks to make a backup file. It will always use the default file name for the backup file (typically the PST name with a .BAK extention).

CSCANPST will append a line to the file called "CSCANPST.LOG" with details of the scan. If the log file does not exist, it will be created.  The appended line will show the file scanned and outcome. Possible outcomes are...

ERROR: User canceled

ERROR: Could not open file
ERROR: File already in use
ERROR: File not found
ERROR: File type not recognized
No errors found
Minor inconsistencies repaired
File repaired

Samples

Entering this command will scan the specified PST file and return to the command prompt...

CSCANPST "C:\Program Files\Common Files\System\Mapi\1033\scanpst.exe" "C:\Documents and Settings\User Profile\Local Settings\Application Data\Microsoft\Outlook\Archive.pst"

Here is a short batch file that will scan the two specified PST files and then report the results...

del CSCANPST.LOG
CSCANPST "C:\Program Files\Microsoft Office\Office12\SCANPST.EXE" "C:\Outlook\main.pst"
CSCANPST "C:\Program Files\Microsoft Office\Office12\SCANPST.EXE" "C:\Outlook\work.pst"
CSCANPST "C:\Program Files\Microsoft Office\Office12\SCANPST.EXE" "C:\Outlook\Spam.pst"
type CSCANPST.LOG

Here is an example of the output in CSCANPST.LOG after running it on my computer (I have a lot of PST files)...

Launched on C:\Users\josh\Documents\Mail\archive.pst...File repaired
Launched on C:\Users\josh\Documents\Mail\mail2005.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Mail2006.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Mail2007-B.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Mail2007.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Mail2008-A.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Spam-062808.pst...File repaired
Launched on C:\Users\josh\Documents\Mail\Spam-0805.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\Spam.pst...No errors found
Launched on C:\Users\josh\Documents\Mail\spam20080908.pst...No errors found

 

FAQ

Q:  How can I find the location of my SCANPST.EXE?
A:  You can do a Windows file search for "SCANPST.EXE". Alternately, check out this helpful page.

Q: How can I find the location of my PST files?
A: You can do a Windows file search for "*.PST". Alternately, check out this helpful page.

Q: How does CSCANPST work?
A: CSCANPST is written in the surprisingly handy AutoHotKey language. It basically runs the SCANPST.EXE then watches for certain strings of words in windows that SCANPST generates. Based on what it sees, it pushes the right buttons to make SCANPST complete its job.

Q: SCANPST poped up a message that CSCANPST does not seem to be responding to.
A: CSCANPST responds to every error I could make happen, but there may be others that only happen in situations that I could not create. If you ever see one of these, please email me and let me know and I will add that case to CSCANPST. A screenshot showing the exact wording on the pop-up message would be very helpful.

Q: I am using a non-English version of Office and CSCANPST doesn't seem to work.
A: Yes, CSCANPST actually looks at the text inside the SCANPST windows to know what to do and when to type, so it will not recognize what is going on in windows that have non-English text. Probably the easiest solution is to find a English version of the SCANPST.EXE executable and run CSCANPST using that. Note that you do not need to install Office in English or even overwrite your existing SCANPST, just get an additional copy of SCANPST in English and use that only from running CSCANPST.

Q: How much does CSCANPST cost?
A: TSMADUMP is free. I do ask that you do not redistribute it- instead, please send people to this webpage so they can download it themselves. It would also be great if you could send an email to me at the support address below so that I can let you know about any updates to the program.

Q: Isn't there an easier/better way to do this?
A: Not that I could find. It does seem like Microsoft could have very easily added a few command-line parameters to SCANPST, but they didn't. Of course the day after I finished CSANPST I found this page. It is very similar to CSANPST, but I think (now that I already made it) that mine is a bit better documented.

If you really love CSCANPST, you can express your gratitude though a tax-deductible donation of any size to my favorite charity, The Aasha Foundation. They spend zero on administration and fundraising, so every dollar you give goes directly to helping the orphans.

Q: What is your relationship to Microsoft, makers of SCANPST?
A: None, except that I am a user of their program. 

Updates

11/3/2008 - First published
11/24/2008 - Fixed broken links and formatting errors that Expression somehow messed up. Sorry.

Support

For support, please email me at...

Be notified of
page updates
powered by
ChangeDetection

support email address

###