Qualys Installation Batch File

A quick and simple way to correctly download and install Qualys via a batch file (must be run as administrator)

@echo off
:: Define Customer and Activation IDs
set "CustomerID=your_customer_ID"
set "ActivationID=your_activation_ID"
set "WebServiceUri=https://qagpublic.qg2.apps.qualys.eu/CloudAgent/"
set "DownloadURL=https://cybertecsecuritytools.com/qualys/windows/QualysCloudAgent.exe"
set "Installer=QualysCloudAgent.exe"

:: Check for administrator privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo.
    echo [ERROR] This script must be run as Administrator.
    echo Please right-click and choose "Run as administrator".
    pause
    exit /b 1
)

echo [INFO] Starting Qualys agent installation...

:: Create a temporary working directory
set "TempDir=%TEMP%\QualysInstall"
mkdir "%TempDir%" >nul 2>&1
cd /d "%TempDir%"

:: Download the installer using curl
echo [INFO] Downloading Qualys agent installer with curl...
curl -L -o "%Installer%" "%DownloadURL%"
if not exist "%Installer%" (
    echo [ERROR] Failed to download the Qualys installer.
    exit /b 1
)

:: Run the installation
echo [INFO] Installing Qualys agent...
"%Installer%" CustomerId=%CustomerID% ActivationId=%ActivationID% WebServiceUri=%WebServiceUri%

:: Wait before checking status
timeout /t 10 >nul

:: Check if Qualys service is running
sc query qualysagent | findstr /i "RUNNING" >nul
if %errorLevel% equ 0 (
    echo [SUCCESS] Qualys agent is installed and running.
) else (
    echo [WARNING] Qualys agent installation may have failed or is not running.
)

:: Clean up
echo [INFO] Cleaning up temporary files...
cd /d "%TEMP%"
rd /s /q "%TempDir%"

echo [INFO] Done.
pause