@echo off
setlocal

:: List of OCX files to unregister and register
set "OCX_FILES=AResize.ocx CFX32.OCX comdlg32.ocx tabctl32.ocx VCF132.OCX"

:: Unregister OCX files from SysWOW64
echo --------------------------------------
echo Unregistering OCX files from SysWOW64:
echo --------------------------------------
for %%f in (%OCX_FILES%) do (
    if exist "C:\Windows\SysWOW64\%%f" (
        regsvr32 /u /s "C:\Windows\SysWOW64\%%f"
        if errorlevel 0 (
            echo %%f unregistered successfully from SysWOW64.
        ) else (
            echo ERROR: Failed to unregister %%f from SysWOW64.
        )
    ) else (
        echo %%f NOT found in SysWOW64, skipping unregister.
    )
)
echo.

:: Re-register OCX files in SysWOW64
echo --------------------------------------
echo Registering OCX files in SysWOW64:
echo --------------------------------------
for %%f in (%OCX_FILES%) do (
    if exist "C:\Windows\SysWOW64\%%f" (
        regsvr32 /s "C:\Windows\SysWOW64\%%f"
        if errorlevel 0 (
            echo %%f registered successfully in SysWOW64.
        ) else (
            echo ERROR: Failed to register %%f in SysWOW64.
        )
    ) else (
        echo %%f NOT found in SysWOW64, skipping register.
    )
)
echo.

:: Open File Explorer at the location of GeoDesigner.exe
echo --------------------------------------
echo Opening File Explorer at GeoDesigner location...

:: Change to the Program Files (x86) directory
pushd "C:\Program Files (x86)"

:: Search for GeoDesigner.exe in folders starting with "GeoDesigner"
for /d %%d in (GeoDesigner*) do (
    if exist "%%d\GeoDesigner.exe" (
        start explorer "%%d"
        echo File Explorer opened at GeoDesigner location: %%d
        goto :end
    )
)

echo ERROR: GeoDesigner.exe not found.
:end
popd
echo.

endlocal
pause
