Community Discussions and Support
Using MBXMAINT in Windows Batch scripts

Many thanks for responding, David.

Yes, you infer correctly. My script detects consistency check failures and then attempts to repair the faulty folders with a "fix" phase - I'm not expecting an automagic fix ;-)

I will look into the possibility of sending you one or more examples, but there is a legal issue here and I have to be certain to avoid comebacks before I send off potentially confidential information. I'm sure you knew this - your request was rather guarded...

 

<P>Many thanks for responding, David.</P> <P>Yes, you infer correctly. My script detects consistency check failures and then attempts to repair the faulty folders with a "fix" phase - I'm not expecting an automagic fix ;-)</P> <P>I will look into the possibility of sending you one or more examples, but there is a legal issue here and I have to be certain to avoid comebacks before I send off potentially confidential information. I'm sure you knew this - your request was rather guarded...</P> <P mce_keep="true"> </P>

After searching for a while, I've drawn a blank, so I have to ask the question...

Has anyone yet figured out how to use MBXMAINT successfully in Windows Batch scripts? I've tried and I just can't get the program to give me a result. Although it appears (?) to perform the function requested, there is no output to stdout or stderr and there is no sensible ERRORLEVEL returned. For example, specifying -CH(ECK) seems to spend time doing something, but regardless of whether the folder is compos mentis or broken, the program returns ERRORLEVEL 1. This is useless. I want to code a program to (1) - scan the users (2000 of them), (2) - decide if any folders are broken, (3) - fix the broken folders and (4) - compress all the folders. Why? Because users frequently omit to close Pegasus when logging off and therefore folders can get corrupted when Pegasus is ungracefully terminated. Turning off the compression option is only partially successful in curing this, but in any case, I need (?) to provide off-line compression as a substitute.

<P>After searching for a while, I've drawn a blank, so I have to ask the question...</P> <P>Has anyone yet figured out how to use MBXMAINT successfully in Windows Batch scripts? I've tried and I just can't get the program to give me a result. Although it appears (?) to perform the function requested, there is no output to stdout or stderr and there is no sensible ERRORLEVEL returned. For example, specifying -CH(ECK) seems to spend time doing something, but regardless of whether the folder is <EM>compos mentis</EM> or broken, the program returns ERRORLEVEL 1. This is useless. I want to code a program to (1) - scan the users (2000 of them), (2) - decide if any folders are broken, (3) - fix the broken folders and (4) - compress all the folders. Why? Because users frequently omit to close Pegasus when logging off and therefore folders can get corrupted when Pegasus is ungracefully terminated. Turning off the compression option is only partially successful in curing this, but in any case, I need (?) to provide off-line compression as a substitute.</P>

[quote user="Rammie"]After searching for a while, I've drawn a blank, so I have to ask the question...[/quote]

Here's David Harris' comment on this:

Ask him to check that he's actually using the latest version of
MBXMAINT - I've just tried it out here, and it works fine as far as I can
tell... The return code is the value of the three-digit number following
the "#" in the last diagnostic printed to the screen, or 0 if no errors
occurred during the process. The program also does extensive
reporting to stdout.

I assume by "Windows batch scripts" he means .CMD or .BAT files?
That's how I did my testing here in any event.

Older versions of MBXMAINT probably weren't great at any of this
because they were an attempt to mix GUI and console in the same
application, which simply doesn't work very well under Windows; but
the newer versions, where the GUI and console versions are split out,
should work exactly the way he wants.

I've just checked, and the versions of MBXMAINT in the public v4.61
are current.

 

<p>[quote user="Rammie"]After searching for a while, I've drawn a blank, so I have to ask the question...[/quote]</p><p>Here's David Harris' comment on this:</p><p><blockquote>Ask him to check that he's actually using the latest version of MBXMAINT - I've just tried it out here, and it works fine as far as I can tell... The return code is the value of the three-digit number following the "#" in the last diagnostic printed to the screen, or 0 if no errors occurred during the process. The program also does extensive reporting to stdout. I assume by "Windows batch scripts" he means .CMD or .BAT files? That's how I did my testing here in any event. Older versions of MBXMAINT probably weren't great at any of this because they were an attempt to mix GUI and console in the same application, which simply doesn't work very well under Windows; but the newer versions, where the GUI and console versions are split out, should work exactly the way he wants. I've just checked, and the versions of MBXMAINT in the public v4.61 are current. </blockquote><p> </p>
			Michael
--
IERenderer's Homepage
PGP Key ID (RSA 2048): 0xC45D831B
S/MIME Fingerprint: 94C6B471 0C623088 A5B27701 742B8666 3B7E657C

This is what I have used. Not the smartest script but seemed to work OK and didn't break anything.

YMMV - comes with no warranty of fitness for purpose or anything else whatsoever.

Paths will need adjusting to your environment.  ... and watch wrapping, doesn't seem to be a \[code\] tag so I used \[quote\]

edit: oh yeah, I use 'grep' & 'cat' from unxutils for win32, I think 'find' (with some contortions) & type can be substituted.

 

[quote]:: should be run from mailstore folder

echo ##### Beginning Run... #####
echo.
:: get list of folders to process
for /f "tokens=*" %%a in ('dir /a:d /b') do (
    echo ##### Processing %%a ##### >> robombx.log
    :: Check PMM's for damage and log errors to file
    echo.
    echo ##### Checking for errors in %%a ##### >> robombx.log
    for %%A in ("%%a\*.PMM") do (
        for /f "tokens=4*" %%B in ('c:\mercury\mbxmaint.exe -CH %%A ^| grep #') do echo %%A %%B %%C >> temp.txt
    )
    if exist temp.txt cat temp.txt >> robombx.log
    if not exist temp.txt echo ALL CLEAR >> robombx.log

    :: Fix ID's in reported folders
    if exist temp.txt echo ##### Fixing errors in %%a ##### >> robombx.log && for /f "tokens=1" %%A in (temp.txt) do c:\mercury\mbxmaint.exe -FI %%A >> robombx.log && erase temp.txt

    :: compact folders
    echo. >> robombx.log
    echo ##### Compressing Folders in %%a ##### >> robombx.log
    c:\mercury\mbxmaint.exe -CO %%a\*.PMM >> robombx.log
)[/quote]

<p>This is what I have used. Not the smartest script but seemed to work OK and didn't break anything.</p><p>YMMV - comes with no warranty of fitness for purpose or anything else whatsoever.</p><p>Paths will need adjusting to your environment.  ... and watch wrapping, doesn't seem to be a \[code\] tag so I used \[quote\]</p><p>edit: oh yeah, I use 'grep' & 'cat' from unxutils for win32, I think 'find' (with some contortions) & type can be substituted.</p><p> </p><p>[quote]:: should be run from mailstore folder echo ##### Beginning Run... ##### echo. :: get list of folders to process for /f "tokens=*" %%a in ('dir /a:d /b') do (     echo ##### Processing %%a ##### >> robombx.log     :: Check PMM's for damage and log errors to file     echo.     echo ##### Checking for errors in %%a ##### >> robombx.log     for %%A in ("%%a\*.PMM") do (         for /f "tokens=4*" %%B in ('c:\mercury\mbxmaint.exe -CH %%A ^| grep #') do echo %%A %%B %%C >> temp.txt     )     if exist temp.txt cat temp.txt >> robombx.log     if not exist temp.txt echo ALL CLEAR >> robombx.log     :: Fix ID's in reported folders     if exist temp.txt echo ##### Fixing errors in %%a ##### >> robombx.log && for /f "tokens=1" %%A in (temp.txt) do c:\mercury\mbxmaint.exe -FI %%A >> robombx.log && erase temp.txt     :: compact folders     echo. >> robombx.log     echo ##### Compressing Folders in %%a ##### >> robombx.log     c:\mercury\mbxmaint.exe -CO %%a\*.PMM >> robombx.log )[/quote] </p>

Thanks, lots of constructive stuff, much appreciated!

IDW/David - well I thought I was using the latest version and I thought I'd double-checked before I asked the question, but perhaps I'm just having a very stupid day.

Dilbert's-thingy - thanks very much! Your script is not unlike mine, but I always have problems with getting parameters to update in FOR structures. I often cop-out by using a separate subroutine script to action the core task. I'll read yours and find out what I'm doing wrong. I need free time to grok it properly. By the way, mine just copies and parses the PMAIL.USR file in Mercury, rather than scanning the folders, but perhaps yours is targetted at multiple folders in a standalone Pegasus installation rather than a Mercury/Pegasus multiuser system(?). Mine also checks for a MAILBOXP.LCK file, just in case a user is logged in.

I'll post when it works properly.

 

<P>Thanks, lots of constructive stuff, much appreciated!</P> <P>IDW/David - well I thought I was using the latest version and I thought I'd double-checked before I asked the question, but perhaps I'm just having a very stupid day.</P> <P>Dilbert's-thingy - thanks very much! Your script is not unlike mine, but I always have problems with getting parameters to update in FOR structures. I often cop-out by using a separate subroutine script to action the core task. I'll read yours and find out what I'm doing wrong. I need free time to grok it properly. By the way, mine just copies and parses the PMAIL.USR file in Mercury, rather than scanning the folders, but perhaps yours is targetted at multiple folders in a standalone Pegasus installation rather than a Mercury/Pegasus multiuser system(?). Mine also checks for a MAILBOXP.LCK file, just in case a user is logged in.</P> <P>I'll post when it works properly.</P> <P mce_keep="true"> </P>

I did say it wasn't a very smart script [:)] - a quick hack to 'get it done now', just reusing a code bit from another script.

It's a relatively small installation and it can be run when I know no-one is logged in.

 

As for your FOR issues, maybe using "setlocal enabledelayedexpansion" and !var! instead of %var% for the relevant vars could help ...

<p>I did say it wasn't a very smart script [:)] - a quick hack to 'get it done now', just reusing a code bit from another script. </p><p>It's a relatively small installation and it can be run when I know no-one is logged in.</p><p> </p><p>As for your FOR issues, maybe using "setlocal enabledelayedexpansion" and !var! instead of %var% for the relevant vars could help ... </p>

Hey! I got it working!

Yes, I had the wrong version of MBXMAINT.EXE (sorry David). Now I'm using the version wrapped with 4.61 and it works a whole lot better.

I'm planning to run the script as part of my 'overnight' set. It's not quite perfect yet, so I won't post until I'm happy.

Interestingly, the "fix" option doesn't fix every folder fault, but since the "compression" option uses belt-and-braces methodology, faulty folders remain no worse off than they started. In every case, these errant folders can be fixed using the normal Pegasus strategy. In addition, I'm quite surprised at how many of my users have corrupt folders that they can't be bothered to fix or report to the helpdesk. This kind-off justifies the need to create the script.

 

<P>Hey! I got it working!</P> <P>Yes, I had the wrong version of MBXMAINT.EXE (sorry David). Now I'm using the version wrapped with 4.61 and it works a whole lot better.</P> <P>I'm planning to run the script as part of my 'overnight' set. It's not quite perfect yet, so I won't post until I'm happy.</P> <P>Interestingly, the "fix" option doesn't fix every folder fault, but since the "compression" option uses belt-and-braces methodology, faulty folders remain no worse off than they started. In every case, these errant folders can be fixed using the normal Pegasus strategy. In addition, I'm quite surprised at how many of my users have corrupt folders that they can't be bothered to fix or report to the helpdesk. This kind-off justifies the need to create the script.</P> <P mce_keep="true"> </P>

I've been using my scheduled task script for some while, to try to keep user folders tidy and consistent. The script processes some 2100 user mailboxes each week. However, I'm still getting frequent errors that MBXMAINT fails to fix. The errors look like:

Performing pre-compaction consistency check...
Checking 'main.pmm'...
Message 6281: expected Ctrl+Z at offset 1056048033.
!! Found internal consistency error:
#016 Character before start of message is not Ctrl+Z.
#017 Could not compact folder because it failed a consistency check.

 This error appears during the compaction phase (obviously) but subsequent to having already run the consistency check successfully on the folder(s). Somehow, the consistency checker is failing to identify this start-of-message error and it's only being trapped by the compaction algorithm. I can fix the errors manually, using the Pegasus right-click tools, but obviously this isn't practical for the (around 300) users who regularly suffer this problem. By the way, I'm fully aware of the cause - users omitting to close Pegasus before logging off - but beyond gentle persuasion, I have no remedy for this. I'm using the latest version of MBXMAINT taken from V4.63.

<P>I've been using my scheduled task script for some while, to try to keep user folders tidy and consistent. The script processes some 2100 user mailboxes each week. However, I'm still getting frequent errors that MBXMAINT fails to fix. The errors look like:</P> <P>Performing pre-compaction consistency check... Checking 'main.pmm'... Message 6281: expected Ctrl+Z at offset 1056048033. !! Found internal consistency error: #016 Character before start of message is not Ctrl+Z. #017 Could not compact folder because it failed a consistency check.</P> <P> This error appears during the compaction phase (obviously) but subsequent to having already run the consistency check successfully on the folder(s). Somehow, the consistency checker is failing to identify this start-of-message error and it's only being trapped by the compaction algorithm. I can fix the errors manually, using the Pegasus right-click tools, but obviously this isn't practical for the (around 300) users who regularly suffer this problem. By the way, I'm fully aware of the cause - users omitting to close Pegasus before logging off - but beyond gentle persuasion, I have no remedy for this. I'm using the latest version of MBXMAINT taken from V4.63.</P>

Just to let you know we're going over this in the test team at the moment.

I need to be clear on one thing though... The consistency check will *never* attempt to fix errors automatically: fixing errors has to be initiated manually, because it has side-effects (recovering deleted messages being the main one). You probably already know this, but there's a way of reading your message that suggests you think the consistency check will initiate a fix if it fails: it won't.

The reading my test team has assumed, though, is that the consistency check succeeds if run on its own, but fails as part of the pre-compaction process: this is what we're looking into. It might be helpful if you could ZIP the PMM and PMI files for an affected folder and send them to me offline so I can test on an actual situation. Any chance you can do this?

Cheers!

-- David --

<p>Just to let you know we're going over this in the test team at the moment. I need to be clear on one thing though... The consistency check will *never* attempt to fix errors automatically: fixing errors has to be initiated manually, because it has side-effects (recovering deleted messages being the main one). You probably already know this, but there's a way of reading your message that suggests you think the consistency check will initiate a fix if it fails: it won't. The reading my test team has assumed, though, is that the consistency check succeeds if run on its own, but fails as part of the pre-compaction process: this is what we're looking into. It might be helpful if you could ZIP the PMM and PMI files for an affected folder and send them to me offline so I can test on an actual situation. Any chance you can do this? Cheers! -- David -- </p>
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft