Intermittent error when starting VatSpy

Lately when I start VatSpy I get the following error. It does not happen every time I start VatSpy. I delete the xml file, and VatSpy will then start, but back to it’s default settings. It’s no great issue, but just wondering what is causing this, and is there a way to resolve it ?

Capture

Doesn’t happen often, no one really seems to know why it happens, but occasionally the xml config file gets corrupted. Have a peek here:

Also, from another forum post:

Usually that error means the config file got corrupted or emptied out somehow so that it’s zero bytes in length. You need to delete it and let VATSpy create a new config file with default settings. To do so, open an explorer window and enter this in the address box:

%appdata%\VAT-Spy

You should see a file called VATSpyConfig or VATSpyConfig.xml. Delete the file, and run VATSpy.

Thanks Don. I remember occasionally having this issue some years ago, and as you point out, deleting the xml and letting VatSpy rebuild the file sorts it. Hadn’t been an issue in a long time, but just recently its cropped up again. Who knows, it may disappear again as suddenly as it appeared ! :slightly_smiling_face:

Fingers crossed it stays away for a while!

I know this is an old thread but this was driving me crazy so I fixed it and thought I should share the fix for anyone else who can use it.

The old forum post about this mentioned that it happens whenever you close VATSpy on a multi-monitor system on the non-primary monitor. For me this is pretty much every time since I have the sim open on the primary monitor and VATSpy etc on the other one. I guess there is a bug in the program when it parses the saved window location and the location is out of bounds of the primary monitor.

This seemed pretty straightforward to fix so I made a batch script:

@echo off
setlocal

rem Get the current user's AppData path
set "configPath=%AppData%\VAT-Spy\VATSpyConfig.xml"

rem Path to the VATSpy application
set "appPath=C:\Program Files (x86)\VATSpy\VATSpy.exe"

rem PowerShell script to modify the XML file
powershell -Command ^
"try { ; ^
    [xml]$xml = Get-Content -Path '%configPath%' ; ^
    $xml.VATSpyConfig.LastWindowLocation.X = '10' ; ^
    $xml.VATSpyConfig.LastWindowLocation.Y = '10' ; ^
    $xml.Save('%configPath%') ; ^
} catch { ; ^
        Write-Host 'An error occurred while modifying the XML file:' $_.Exception.Message ; exit 1 ; ^
}"

rem Check if the PowerShell command was successful
if %ERRORLEVEL% neq 0 (
    echo Failed to update the XML file.
    exit /b 1
)

rem Start the VATSpy application
start "" "%appPath%"

endlocal

All it does is update the co-ordinates of the saved window location to 10, 10 and then opens up VATSpy. If you have installed VATSpy in a non-standard location you may need to change the path in the script.

I just put this batch script in the same location as the VATSpy exe file, and created a shortcut to it on my desktop. You can change the properties of the shortcut so it has the same icon as VATSpy, and rename it to VATSpy so it doesn’t look odd. You will notice a command prompt window briefly flash up before VATSpy opens when you use the shortcut, and you will find that no matter where the VATSpy window is when you close it, you can open it again using this shortcut and it will not crash.