EN
Español
English
Português
    Repair Agent SourceList Installed with the Renamed Installer

    Warning: The Windows Agent installer with .msi extension should be used only for Domain Policy (GPO) deployments. The installer should not be renamed, as it may prevent upgrading to future versions; in that case, the agents would need to be reinstalled.

    Note: This procedure applies to versions higher than 9.20.

    What to do if the installer has already been renamed and the agents were installed in that state? The following procedure corrects the Windows Installer registry so that the agent can be updated to future versions without needing to reinstall it.

    What is it?

    Fix-ArandaAgentSourceList.bat is a script that locates, within HKEY_CLASSES_ROOT\Installer\Products, the key to the product Aranda Agent 9 and updates the value PackageName of your subkey SourceList with the original installer name (Aranda Agent 9.msi). Before you modify the record, export a backup .reg of the complete key in %TEMP%\RegistryBackups.

    For what?

    Windows Installer uses the PackageName of SourceList to locate the original MSI package when applying an update or patch to the agent. If the agent was installed with a renamed installer, that value does not match the expected name, and subsequent updates fail. The script corrects the value without uninstalling or reinstalling the agent.

    How does it work?

    1. Upload the script as a software package:

    a. Copy the full contents of the script shown below.

    b. Paste it into a text editor, such as Windows Notepad.

    c. Save the file with extension .bat (e.g., Fix-ArandaAgentSourceList.bat). When saving, select the All Files in the “Type” field, otherwise the editor adds the extension .txt by default.

    d. Upload the file .bat as a software package. View Packages

    @echo off
    setlocal enabledelayedexpansion
    
    rem ============================================================
    rem Busca en HKEY_CLASSES_ROOT\Installer\Products la clave cuyo
    rem valor ProductName sea "Aranda Agent 9". Antes de modificarla,
    rem exporta un respaldo .reg de la clave completa a una carpeta
    rem temporal. Luego actualiza PackageName dentro de SourceList.
    rem
    rem Debe ejecutarse como Administrador.
    rem ============================================================
    
    set "PRODUCTNAME=Aranda Agent 9"
    set "NEWPACKAGENAME=Aranda Agent 9.msi"
    set "ROOTKEY=HKEY_CLASSES_ROOT\Installer\Products"
    
    rem --- Verificar permisos de administrador ---
    net session >nul 2>&1
    if not %errorlevel% == 0 (
        echo Este script requiere permisos de Administrador.
        echo Haz clic derecho sobre el archivo y selecciona "Ejecutar como administrador".
        exit /b 1
    )
    
    echo Buscando clave con ProductName = "%PRODUCTNAME%" ...
    
    set "FOUNDKEY="
    
    for /f "tokens=*" %%K in ('reg query "%ROOTKEY%" 2^>nul') do (
        set "SUBKEY=%%K"
        if not "!SUBKEY!"=="%ROOTKEY%" if not "!SUBKEY!"=="" (
            for /f "tokens=2,*" %%A in ('reg query "!SUBKEY!" /v ProductName 2^>nul ^| findstr /i "ProductName"') do (
                set "PNAME=%%B"
                if /i "!PNAME!"=="%PRODUCTNAME%" (
                    set "FOUNDKEY=!SUBKEY!"
                )
            )
        )
    )
    
    if "%FOUNDKEY%"=="" (
        echo No se encontro ninguna clave con ProductName = "%PRODUCTNAME%"
        exit /b 1
    )
    
    echo Clave encontrada: %FOUNDKEY%
    
    set "SOURCELISTKEY=%FOUNDKEY%\SourceList"
    
    reg query "%SOURCELISTKEY%" >nul 2>&1
    if not %errorlevel% == 0 (
        echo La subclave SourceList no existe en %FOUNDKEY%
        exit /b 1
    )
    
    rem --- Respaldo de la clave completa antes de modificarla ---
    set "BACKUPDIR=%TEMP%\RegistryBackups"
    if not exist "%BACKUPDIR%" mkdir "%BACKUPDIR%"
    
    set "STAMP=%date%_%time%"
    set "STAMP=%STAMP::=-%"
    set "STAMP=%STAMP:/=-%"
    set "STAMP=%STAMP:,=-%"
    set "STAMP=%STAMP: =_%"
    set "STAMP=%STAMP:.=-%"
    
    for %%N in ("%FOUNDKEY%") do set "KEYNAME=%%~nN"
    
    set "BACKUPFILE=%BACKUPDIR%\Installer_Products_%KEYNAME%_%STAMP%.reg"
    
    reg export "%FOUNDKEY%" "%BACKUPFILE%" /y
    if not %errorlevel% == 0 (
        echo No se pudo crear el respaldo de la clave. Se aborta antes de modificar el registro.
        exit /b 1
    )
    if not exist "%BACKUPFILE%" (
        echo El archivo de respaldo no se genero. Se aborta antes de modificar el registro.
        exit /b 1
    )
    
    echo Respaldo creado en: %BACKUPFILE%
    
    rem --- Modificar PackageName en SourceList ---
    for /f "tokens=2,*" %%A in ('reg query "%SOURCELISTKEY%" /v PackageName 2^>nul ^| findstr /i "PackageName"') do (
        echo Valor actual de PackageName: %%B
    )
    
    reg add "%SOURCELISTKEY%" /v PackageName /t REG_SZ /d "%NEWPACKAGENAME%" /f
    if not %errorlevel% == 0 (
        echo No se pudo actualizar PackageName.
        exit /b 1
    )
    
    for /f "tokens=2,*" %%A in ('reg query "%SOURCELISTKEY%" /v PackageName 2^>nul ^| findstr /i "PackageName"') do (
        echo Nuevo valor de PackageName: %%B
    )
    
    echo Actualizacion completada correctamente.
    endlocal
    

    2. Create the distribution project for the package. See Software Distribution

    3. Associate only the devices on which the agent was installed with the renamed installer.

    4. Run the distribution project and verify that it completes successfully.

    5. Force the agent to update from the console using the appropriate action, or wait for the automatic update task to run.

    6. Confirm that the agent is updated successfully. If the problem persists, uninstall the agent and reinstall it using the installer with .exe extension.