Large balance deviations from bank in MSMoney data files

Dale Webb 10 Reputation points
2026-04-18T00:16:34.0166667+00:00

Was running MS Money with app on my laptop and the data file on my Beestation device.  When balancing my checkbook and credit card accounts, I started finding very large deviations from my actual balance.

Inquired here and was told that running the program with the data file on external storage was causing the problem, and kindly set up script for me to run that:

Compared the data file on the external storage with one that exists on my work directory > if the data file on external storage was NEWER than the one in the work directory, copied the data file to the work directory on my computer drive, overwriting the old file (same name) > Opened MS Money and allowed the data file to be edited in MS Money > when MS Money was closed > script copied the data file in the work directory BACK to the external storage and terminated the storage.

Had a crash and lost access to the script written for me.  Asked ChatGPT to write me one that did the same thing, viz:

 

@echo off

setlocal

 

:: ================================

:: CONFIGURATION

:: ================================

set "MasterFile=H:\files\personal\money\dkwebb.mny"

set "LocalDir=C:\Users\dale-\Documents\MoneyWork"

set "LocalFile=%LocalDir%\dkwebb.mny"

 

echo === Microsoft Money Sync Script ===

echo Master file: %MasterFile%

echo Working file: %LocalFile%

echo.

 

:: ================================

:: Ensure working directory exists

:: ================================

if not exist "%LocalDir%" (

    echo Creating working directory: %LocalDir%

    mkdir "%LocalDir%"

)

 

:: ================================

:: Validate master file exists

:: ================================

if not exist "%MasterFile%" (

    echo ERROR: Master file not found!

    echo %MasterFile%

    pause

    exit /b 1

)

 

:: ================================

:: Check if master is newer

:: ================================

echo Checking if master file is newer...

for %%A in ("%MasterFile%") do set "MasterTime=%%~tA"

for %%B in ("%LocalFile%") do set "LocalTime=%%~tB"

 

if not exist "%LocalFile%" (

    echo Working file missing — copying fresh copy...

    robocopy "%~dpMasterFile%" "%LocalDir%" "dkwebb.mny" /COPY:DAT /R:1 /W:1 >nul

) else (

    if "%MasterTime%" GTR "%LocalTime%" (

        echo Master is newer — syncing to working copy...

        robocopy "%~dpMasterFile%" "%LocalDir%" "dkwebb.mny" /COPY:DAT /R:1 /W:1 >nul

    ) else (

        echo Working copy is up to date.

    )

)

 

:: ================================

:: Verify working file exists

:: ================================

if not exist "%LocalFile%" (

    echo ERROR: Working copy missing after sync.

    echo %LocalFile%

    pause

    exit /b 1

)

 

:: ================================

:: Launch Microsoft Money

:: ================================

echo Launching Microsoft Money...

start "" "%LocalFile%"

 

echo.

echo When you close Money, the script will sync changes back to master.

echo.

pause

 :: ================================

:: Sync working copy back to master

:: ================================

echo Syncing changes back to master...

robocopy "%LocalDir%" "%~dpMasterFile%" "dkwebb.mny" /COPY:DAT /R:1 /W:1 >nul

 

echo Sync complete.

pause

exit /b 0

 

Worked for a while, but the last couple of months, I have begun seeing the huge balance differences when balancing.

Could someone explain the problems to me so I can fix them?

 

Windows for home | Windows 11 | Files, folders, and storage
0 comments No comments

1 answer

Sort by: Oldest
  1. AI answer

    2026-04-18T00:16:53.35+00:00

    The batch file has several logic and robustness issues that can easily lead to using the wrong copy of the Money file and cause the large balance deviations being seen.

    Key problems in the script:

    1. Unreliable time comparison
    • The script compares file timestamps as strings:
        for %%A in ("%MasterFile%") do set "MasterTime=%%~tA"
        for %%B in ("%LocalFile%") do set "LocalTime=%%~tB"
        if "%MasterTime%" GTR "%LocalTime%" (
      
    • %%~tA returns a localized date/time string (e.g., 4/18/2026 9:05 AM). String comparison with GTR is not reliable across different date formats, 12/24‑hour times, or single‑digit days/months.
    • Result: the script may incorrectly decide that the master is older when it is actually newer (or vice versa), so the wrong file becomes the “authoritative” one.
    1. Use of %~dpMasterFile% is invalid
    • "%~dpMasterFile%" only works on parameters like %1, not on environment variables.
    • In this script, %~dpMasterFile% expands to an empty string, so robocopy effectively runs with a blank source directory:
        robocopy "%~dpMasterFile%" "%LocalDir%" "dkwebb.mny" ...
      
    • Depending on how cmd parses this, robocopy may:
      • Fail silently (no copy actually happens), or
      • Use the current directory as source.
    • That means the working file might not be updated from the external drive at all, or might be overwritten from the wrong location.
    1. No error checking on robocopy
    • robocopy returns exit codes that indicate success, partial success, or failure.
    • The script ignores these codes and always continues as if the copy worked.
    • If the external drive is missing, goes to sleep, or has I/O errors, the script may:
      • Leave an old working file in place, or
      • Fail to copy changes back to the master.
    • Over time, this leads to divergence between the two copies.
    1. Race conditions and multiple runs
    • The script assumes:
      • Only one instance runs at a time.
      • Money is always closed before the final robocopy back to master.
    • If the script is started twice, or Money is still flushing data when the script copies back, the master can be overwritten with a partially updated or stale file.
    1. No protection against direct edits on the master
    • If Money is ever opened directly on H:\...\dkwebb.mny (bypassing the script), changes there may be overwritten by the next script run, depending on the timestamp comparison.
    1. No backup/rotation
    • The script overwrites the master with the working copy every time without keeping any previous versions.
    • Any corruption or bad state in the working file is immediately propagated to the master, with no way to roll back.

    How to fix the approach (conceptually):

    1. Fix path handling
    • Replace %~dpMasterFile% with a proper source directory variable:
        set "MasterDir=H:\files\personal\money"
        set "MasterFile=%MasterDir%\dkwebb.mny"
      
      Then use "%MasterDir%" as the robocopy source.
    1. Avoid string‑based time comparison
    • Either:
      • Always treat the external file as the master and copy it down unconditionally at start, or
      • Use a more robust comparison method (for example, a PowerShell helper that compares LastWriteTime as a DateTime, not as a string).
    1. Check robocopy exit codes
    • After each robocopy, check %ERRORLEVEL% and abort with a clear message if the copy failed instead of silently continuing.
    1. Enforce single‑instance and close‑before‑sync
    • Use a simple lock file or check for a running msmoney.exe process before copying back.
    1. Add backups
    • Before overwriting the master, copy it to a dated backup file on the external drive so there is a recovery point if balances go wrong.

    Given that large deviations are already appearing, the data file is likely out of sync or partially corrupted. The safest next steps are:

    • Identify the most recent known‑good .mny file (from backups, old copies, or the external drive).
    • Stop using the current script until it is corrected.
    • Restore from the known‑good file and then adopt a simpler, safer workflow (for example, keep the master only on the local drive and back it up to the external device, not the other way around).

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.