Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Batch Script

  • 05-03-2012 12:46pm
    #1
    Closed Accounts Posts: 106 ✭✭


    SCRIPTING HELP

    Sup lads; perhaps one of you know scripting?
    REM ***This batch file will automatically run SCANPST on every PST file in the
    REM ***directory specified by PST_FILE_MASK.

    set SCANPST_PATH="C:\Program Files\Microsoft Office\Office12\SCANPST.EXE"
    set PST_FILE_MASK="C:\Users\josh\Documents\Mail\*.pst"
    set scandirs="

    REM *** CD into in the directory that contains the launched batch file...
    cd %~dp0

    del cscanpst.log

    for %%i in (%PST_FILE_MASK%) do (

    REM Add an N to the end of the following line of you don't want backup files

    cscanpst.exe %SCANPST_PATH% "%%i"
    if errorlevel 3 goto done
    )
    :done

    @echo Log:
    @type cscanpst.log

    @pause
    What this does, is take the PST_FILE_MASK as the location, and run's scanPST against all PST's in that directory.

    How do i modify it to take all sub directories, within a specific directory and scan for *.pst? so instead of \Users\josh\Documents\Mail\*.pst it will take C:\*\*.pst?
    (that doesn't work btw i tried :lol: )


Comments

  • Registered Users, Registered Users 2 Posts: 1,306 ✭✭✭carveone


    Yes, don't do it quite that way. You need to seperate the path from the wildcard and then use "for /r":
    set SCANPST_PATH="C:\Program Files\Microsoft Office\Office12\SCANPST.EXE"
    set PST_FILE_MASK="*.pst"
    set PST_FILE_DIR="C:\Users\josh\Documents\Mail"
    
    cd %~dp0
    
    del cscanpst.log
    
    for /R %PST_FILE_DIR% %%i in (%PST_FILE_MASK%) do (
    
    cscanpst.exe %SCANPST_PATH% "%%i"
    if errorlevel 3 goto done
    )
    :done
    
    @echo Log:
    @type cscanpst.log
    
    @pause 
    
    

    Like that. By the way there's a very subtle bug:
    cd %~dp0

    will not change drive if that drive isn't the current drive if you know what I mean. In other words if you are in "d:\home", and do "cd c:\users\foo" then you are still in D:!!

    Do it like this:
    cd %~d0
    cd %~p0
    

    Hope this helps.


  • Registered Users, Registered Users 2 Posts: 1,306 ✭✭✭carveone


    By the way, help is available for each command by going "help command". So "help for" will give you the parameters for for. The most useful of all is "help set".

    Also this link:

    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true


Advertisement