@echo off setlocal EnableDelayedExpansion title WhatsApp Sender - Bulletproof Auto Installer color 0A :: ================================================================ :: STEP 0: Pre-flight Checks (Admin & Internet) :: ================================================================ echo. echo ============================================================= echo WhatsApp Sender ^| Full Auto Installer echo ============================================================= echo. :: Check Admin Rights net session >nul 2>&1 if %errorLevel% neq 0 ( echo [!] Administrative privileges required. Restarting as Admin... powershell -Command "Start-Process '%~dpnx0' -Verb RunAs" exit /b ) :: Check Internet Connection echo Checking internet connection... ping 8.8.8.8 -n 1 -w 2000 >nul if %errorLevel% neq 0 ( color 0C echo [ERROR] No internet connection detected. Please check network. pause exit /b 1 ) echo [OK] Internet connection verified. set "BASE_DIR=C:\whatsapp-sender" set "SETUP_DIR=%BASE_DIR%\MsSetup" set "NODE_MSI=%SETUP_DIR%\node-v24.16.0-x64.msi" set "PS1_SCRIPT=%~dp0InstallNJs.ps1" set "PDF_URL=https://8446606380.com/share/whatsapp-sender/sample.pdf" set "PDF_DEST=%BASE_DIR%\sample.pdf" :: ================================================================ :: STEP 1: Directory Setup :: ================================================================ echo. echo --------------------------------------------------------------- echo [STEP 1/5] Preparing directories... echo --------------------------------------------------------------- if not exist "%BASE_DIR%" mkdir "%BASE_DIR%" if not exist "%SETUP_DIR%" mkdir "%SETUP_DIR%" echo [OK] Directories ready at %BASE_DIR% :: ================================================================ :: STEP 2: Execute Downloader :: ================================================================ echo. echo --------------------------------------------------------------- echo [STEP 2/5] Downloading Node.js framework... echo --------------------------------------------------------------- if not exist "%PS1_SCRIPT%" ( color 0C echo [ERROR] InstallNJs.ps1 not found in the current directory! echo Please ensure both files are in the same folder. pause exit /b 1 ) powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS1_SCRIPT%" if %ERRORLEVEL% NEQ 0 ( color 0C echo [ERROR] Download process failed. Check the log in %SETUP_DIR%. pause exit /b 1 ) :: ================================================================ :: STEP 3: Install Node.js :: ================================================================ echo. echo --------------------------------------------------------------- echo [STEP 3/5] Installing Node.js (Silent)... echo --------------------------------------------------------------- msiexec.exe /i "%NODE_MSI%" /qb! REBOOT=ReallySuppress if %ERRORLEVEL% NEQ 0 ( color 0C echo [ERROR] Installer exited with code %ERRORLEVEL%. pause exit /b 1 ) echo [OK] Installation applied. Refreshing system environment... :: Force refresh of PATH variable for current session for /f "usebackq skip=2 tokens=3*" %%A in (`reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH 2^>nul`) do set "SYS_PATH=%%A %%B" set "PATH=C:\Program Files\nodejs;%SYS_PATH%;%PATH%" node --version >nul 2>&1 if %ERRORLEVEL% NEQ 0 ( color 0C echo [ERROR] Node.js is not responding. System reboot may be required. pause exit /b 1 ) echo [OK] Node Environment Active. node --version call npm --version :: ================================================================ :: STEP 4: Project Initialization & NPM (Sequential List) :: ================================================================ echo. echo --------------------------------------------------------------- echo [STEP 4/5] Setting up WhatsApp Client packages... echo --------------------------------------------------------------- cd /d "%BASE_DIR%" echo ^> Initializing npm... call npm init -y echo. echo ^> Installing whatsapp-web.js... call npm install whatsapp-web.js echo. echo ^> Installing qrcode... call npm install qrcode echo. echo ^> Installing puppeteer... call npm install puppeteer echo. echo ^> Installing open... call npm install open echo. echo ^> Installing qrcode-terminal... call npm install qrcode-terminal echo. echo ^> Generating Installation List... call npm list :: ================================================================ :: STEP 5: Download PDF File :: ================================================================ echo. echo --------------------------------------------------------------- echo [STEP 5/5] Downloading PDF Document... echo --------------------------------------------------------------- echo ^> Fetching %PDF_URL% ... powershell -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { Invoke-WebRequest -Uri '%PDF_URL%' -OutFile '%PDF_DEST%' -UseBasicParsing; Write-Host ' [OK] PDF successfully downloaded to %PDF_DEST%' -ForegroundColor Green } catch { Write-Host ' [ERROR] Failed to download PDF: $_' -ForegroundColor Red; exit 1 }" if %ERRORLEVEL% NEQ 0 ( color 0C echo [ERROR] PDF Download failed. Check network or URL validity. pause exit /b 1 ) :: ================================================================ :: FINISH :: ================================================================ echo. echo ============================================================= echo ALL DONE - Client environment successfully configured! echo ============================================================= echo Path : %BASE_DIR% echo PDF : %PDF_DEST% echo ============================================================= echo. echo Launching A01.js ... start "WhatsApp Sender" cmd.exe /k "cd /d "%BASE_DIR%" && node A01.js "918446606380" "C:\whatsapp-sender\sample.pdf" """ pause