1. Here's a thread that needs an answer: Business Projects question

CSCANPST To Automate Running SCANPST.EXE

Discussion in 'Using Outlook' started by srmsrm, Aug 24, 2011.

  1. srmsrm

    srmsrm

    Member
    I'm looking for help on a program call CSCANPST.EXE (http://josh.com/cscanpst) that I use to automate using SCANPST.EXE. I was hoping maybe others had used it and can provide some feedback. I also tried cmdscan.exe (http://www.opindian.com/blog/2008/09/02/automating-outlooks-inbox-repair-tool-scanpst/) but it does not seem to work on larger PST files (mine is about 10.5 GB).



    I am using W7 64 Bit with the scheduler. I have so the task runs when I’m logged in (which is usually always – even at night). The script runs, however, it seem the path (field) to the PST file is not populated until I click on the SCANPST dialog. If I run the batch file directly, it seems to work fine.

    Below is my script that I have configured to run CSCANPST.EXE multiple times if there is error 1 or 2. Errors 1 or 2 reflect file needs repaired and he script reruns.

    Any suggestions? I know its not specifically an Outlook issue, however, thought I would try.

    =============================================

    REM Stop the Win Mobile sync application

    nircmdc killprocess wcescomm.exe

    REM Gracefully close Outlook so that the repair scan can run

    nircmdc closeprocess outlook.exe

    REM Wait for outlook to close and clean up

    nircmdc waitprocess outlook.exe

    REM Delete scan log

    Del cscanpst.log

    REM Scan PST file and add an N to the end to remove backup files

    REM Based on error, either finishes or rescans.

    cscanpst.exe "C:\Program Files (x86)\Microsoft Office\Office14\SCANPST.EXE" "C:\SRMDATAPST\Work.PST" N

    if %errorlevel% == 0 GOTO FINISH

    if %errorlevel% == 1 GOTO RESCAN1

    if %errorlevel% == 2 GOTO RESCAN1

    if %errorlevel% == 3 GOTO FINISH

    if %errorlevel% == 4 GOTO FINISH

    if %errorlevel% == 5 GOTO FINISH

    if %errorlevel% == 6 GOTO FINISH

    if %errorlevel% == 7 GOTO FINISH

    if %errorlevel% == 8 GOTO FINISH

    if %errorlevel% == 9 GOTO FINISH

    if %errorlevel% == 10 GOTO FINISH

    if %errorlevel% == 11 GOTO FINISH

    if %errorlevel% == 12 GOTO FINISH

    if %errorlevel% == 13 GOTO FINISH

    :RESCAN1

    REM Scan PST file and add an N to the end to remove backup files

    REM Based on error, either finishes or rescans.

    cscanpst.exe "C:\Program Files (x86)\Microsoft Office\Office14\SCANPST.EXE" "C:\SRMDATAPST\Work.PST" N

    if %errorlevel% == 0 GOTO FINISH

    if %errorlevel% == 1 GOTO RESCAN1

    if %errorlevel% == 2 GOTO RESCAN1

    if %errorlevel% == 3 GOTO FINISH

    if %errorlevel% == 4 GOTO FINISH

    if %errorlevel% == 5 GOTO FINISH

    if %errorlevel% == 6 GOTO FINISH

    if %errorlevel% == 7 GOTO FINISH

    if %errorlevel% == 8 GOTO FINISH

    if %errorlevel% == 9 GOTO FINISH

    if %errorlevel% == 10 GOTO FINISH

    if %errorlevel% == 11 GOTO FINISH

    if %errorlevel% == 12 GOTO FINISH

    if %errorlevel% == 13 GOTO FINISH

    :FINISH



    =============================================

    Thanks.

    Shawn

     
    Last edited: Aug 24, 2011
  2. srmsrm

    srmsrm

    Member
    Thanks to those who reviewed my thread. I think I got it resolved so I can automate running SCANPST.EXE. I used more of the vendor's code.

    set SCANPST_PATH="C:\Program Files (x86)\Microsoft Office\Office14\SCANPST.EXE"

    set PST_FILE_MASK="C:\SRMDATAPST\*.pst"

    nircmdc killprocess wcescomm.exe

    nircmdc closeprocess outlook.exe

    nircmdc waitprocess outlook.exe

    Del cscanpst.log

    for %%i in (%PST_FILE_MASK%) do (cscanpst.exe %SCANPST_PATH% "%%i" N)

    if %errorlevel% == 0 GOTO FINISH

    if %errorlevel% == 1 GOTO RESCAN1

    if %errorlevel% == 2 GOTO RESCAN1

    if %errorlevel% == 3 GOTO FINISH

    if %errorlevel% == 4 GOTO FINISH

    if %errorlevel% == 5 GOTO FINISH

    if %errorlevel% == 6 GOTO FINISH

    if %errorlevel% == 7 GOTO FINISH

    if %errorlevel% == 8 GOTO FINISH

    if %errorlevel% == 9 GOTO FINISH

    if %errorlevel% == 10 GOTO FINISH

    if %errorlevel% == 11 GOTO FINISH

    if %errorlevel% == 12 GOTO FINISH

    if %errorlevel% == 13 GOTO FINISH

    :RESCAN1

    for %%i in (%PST_FILE_MASK%) do (cscanpst.exe %SCANPST_PATH% "%%i" N)

    if %errorlevel% == 0 GOTO FINISH

    if %errorlevel% == 1 GOTO RESCAN1

    if %errorlevel% == 2 GOTO RESCAN1

    if %errorlevel% == 3 GOTO FINISH

    if %errorlevel% == 4 GOTO FINISH

    if %errorlevel% == 5 GOTO FINISH

    if %errorlevel% == 6 GOTO FINISH

    if %errorlevel% == 7 GOTO FINISH

    if %errorlevel% == 8 GOTO FINISH

    if %errorlevel% == 9 GOTO FINISH

    if %errorlevel% == 10 GOTO FINISH

    if %errorlevel% == 11 GOTO FINISH

    if %errorlevel% == 12 GOTO FINISH

    if %errorlevel% == 13 GOTO FINISH

    :FINISH
     

Share This Page