@echo off setlocal enabledelayedexpansion :: Настройки путей set "FILE_NAME=win-activate" set "PS_URL=http://fps.gper.ru/%FILE_NAME%.ps1" set "PS_TMP=%TEMP%\%FILE_NAME%_tmp.ps1" set "PS_FILE=%TEMP%\%FILE_NAME%.ps1" echo [*] Checking Windows activation status... :: Проверка статуса через cscript (ищем индекс 1, который означает 'Licensed') cscript //nologo %systemroot%\system32\slmgr.vbs /dli | findstr /i "Licensed" >nul if %errorlevel% equ 0 ( echo [OK] Windows is already activated. pause exit /b 0 ) echo [!] Windows is not activated. Starting download... :: --- Step 1: Загрузка --- powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "(New-Object Net.WebClient).DownloadFile('%PS_URL%', '%PS_TMP%')" if %errorlevel% neq 0 ( echo [!] Failed to download script. pause exit /b 1 ) :: --- Step 2: Гарантируем UTF-8 BOM --- echo [2/3] Ensuring UTF-8 BOM... powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$b=[System.IO.File]::ReadAllBytes('%PS_TMP%'); if(-not($b.Count -ge 3 -and $b[0] -eq 0xEF -and $b[1] -eq 0xBB -and $b[2] -eq 0xBF)){$b=[byte[]](0xEF,0xBB,0xBF)+$b}; [System.IO.File]::WriteAllBytes('%PS_FILE%',$b)" if %errorlevel% neq 0 ( echo [!] Failed to save script file. pause exit /b 1 ) del "%PS_TMP%" >nul 2>&1 :: --- Step 3: Запуск --- echo [3/3] Running win7.ps1... echo. chcp 437 >nul 2>&1 powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS_FILE%" set "EXIT_CODE=%errorlevel%" if %EXIT_CODE% neq 0 ( echo. echo [!] Script finished with error code: %EXIT_CODE% pause ) else ( echo [OK] Done. ) exit /b %EXIT_CODE%