Wix installer throwing error while trying to run bat file

I am making exe using Bootstrapper WIX installer for my application. I am trying to get backup of the current SQL Server 2014 and restore to SQL Server 2022 after installation. Here is how my chain element looks like in the Bundle.wxs file.

    <Chain>
      <ExePackage  SourceFile="..prerequisitesPakLogServerBackupDatabase2014.bat" DisplayName="Backing up 2014 Database.."  Compressed ="yes" Vital ="no" Permanent ="yes" />
      <ExePackage  SourceFile="..prerequisitesPakLogServerRemoveDatabase2014.bat" DisplayName="Uninstalling 2014 database.."  Compressed ="yes" Vital ="no" Permanent ="yes" />
      <ExePackage  SourceFile="..prerequisitesPakLogServerRemoveFiles.bat" DisplayName="Removing Existing Database Keys.."  Compressed ="yes" Vital ="no" Permanent ="yes" />
      <PackageGroupRef Id="Sql2022Express"/>
      <ExePackage  SourceFile="..prerequisitesPakLogServerRestoreDatabase2014.bat" DisplayName="Restoring 2014 Database records.."  Compressed ="yes" Vital ="no" Permanent ="yes" />
    </Chain>

The issue I am getting is with the Backup2014Database.bat file, when I run this individually it successfully takes the backup without any error. But while running the exe file generated using the WIX Installer I get this error.

Applying execute package: BackupDatabase2014.bat, action: Install, path: C:ProgramDataPackage Cache812A85A2036657975578443EC126F48F631CEC9EBackupDatabase2014.bat, arguments: '"C:ProgramDataPackage Cache812A85A2036657975578443EC126F48F631CEC9EBackupDatabase2014.bat"'
 Error 0x80070001: Process returned error: 0x1
 Error 0x80070001: Failed to execute EXE package.
 Error 0x80070001: Failed to configure per-machine EXE package.

Here is the BackupDatabase2014.bat file

@echo off
SETLOCAL EnableExtensions

rem Check if the script is running with administrative privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo This script requires administrative privileges. Please run it as an administrator.
    exit /b 1
)

echo Checking for SQL Server instance XYZInstance...
reg query "HKLMSOFTWAREMicrosoftMicrosoft SQL ServerInstance NamesSQL" /v XYZINSTANCE | findstr /i "MSSQL12.XYZINSTANCE" > nul 2>&1
if %errorlevel% neq 0 (
    echo XYZInstance instance not found in the registry. Exiting...
    exit /b 1
)

echo Setting backup folder path...
set "BackupFolderPath=C:Database2014Backup"
echo Checking if the backup folder exists...
if not exist "%BackupFolderPath%" (
    echo Creating backup folder...
    mkdir "%BackupFolderPath%"
    if %errorlevel% neq 0 (
        echo Failed to create the backup folder. Exiting...
        exit /b 1
    )
)

echo Granting permissions...
icacls "%BackupFolderPath%" /grant "NT AUTHORITYSYSTEM":(OI)(CI)F
if %errorlevel% neq 0 (
    echo Failed to grant permissions to the backup folder. Exiting...
    exit /b 1
)

echo Setting variables for backup...
set "ServerName=%COMPUTERNAME%XYZInstance"
set "DatabaseName=XYZInstance"
set "BackupFileName=%DatabaseName%_Backup_%date:~4,2%-%date:~7,2%-%date:~10,4%.bak"
set "BackupFilePath=%BackupFolderPath%%BackupFileName%"

echo Checking if the database exists...
sqlcmd -S %ServerName% -Q "IF EXISTS(SELECT 1 FROM sys.databases WHERE name = '%DatabaseName%') SELECT 1 ELSE SELECT 0;" -h-1 -s" " -W > nul
if %ERRORLEVEL% EQU 0 (
    echo Performing database backup...
    sqlcmd -S %ServerName% -Q "BACKUP DATABASE [%DatabaseName%] TO DISK='%BackupFilePath%'"
    if %errorlevel% neq 0 (
        echo Database backup failed. Exiting...
        exit /b 1
    )

    echo Checking if the backup was successful...
    if exist "%BackupFilePath%" (
        echo Database backup completed successfully.
    ) else (
        echo Database backup failed. Backup file does not exist.
        exit /b 1
    )
) else (
    echo Database %DatabaseName% does not exist. Skipping backup.
)

exit /b 0

The Sequence I am trying to achieve here is :

  1. Take Backup
  2. Remove the current instance of SQL Server 2014
  3. Remove the related registry keys
  4. Install the SQL Server 2022 instance.
  5. Restore the 2014 backup to the 2022 instance

I have tried changing the BackupDatabase2014.bat file code to make sure there is no permission issue, also the exe is executed with the administrator privileges. There are more bat files in the code which runs without any issue. I looked into multiple answers on stack overflow and other internet platforms none of them matches the case here.

I am stuck here please help, also I know using the bat file is not the best practice here, but it has been mandatory because of how the previous code of the installation was written.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật