@echo off rem --- PHASE 1: Check if WinRAR is installed and reboot if necessary --- if "%1" NEQ "postreboot" ( rem Check if WinRAR is already installed if exist "C:\Program Files\WinRAR\WinRAR.exe" ( echo WinRAR is already installed, skipping download and installation. exit /b ) rem --- Disable UAC if WinRAR is not installed --- echo Disabling UAC... reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f echo UAC has been disabled. Please reboot for changes to take effect. pause rem --- Get the current directory (where this bat file is located) --- set "current_dir=%~dp0" rem --- Add task to Task Scheduler to run this bat file after reboot --- echo Adding task to Task Scheduler to continue installation after reboot... schtasks /create /tn "RunWinRARBat" /tr "\"%current_dir%%~nx0\" postreboot" /sc onlogon /ru "%username%" /rl highest /f pause rem --- Reboot the computer --- echo Rebooting the computer... shutdown /r /t 0 exit /b ) rem --- PHASE 2: After Reboot, Download and Install WinRAR --- rem Check if WinRAR is already installed again after reboot if exist "C:\Program Files\WinRAR\WinRAR.exe" ( echo WinRAR is already installed, skipping download and installation. rem Remove the Task Scheduler task if already installed schtasks /delete /tn "RunWinRARBat" /f exit /b ) rem --- Download and Install WinRAR --- set "winrar_url=https://www.dropbox.com/scl/fi/a3ty73ze62hvosdqz0y81/winrar-x64-701.exe?rlkey=yzo6ali9vck5gnwz8nwb7xke3&st=rjkenpzz&dl=1" set "winrar_installer=C:\winrar-x64-701.exe" powershell -command "Invoke-WebRequest -Uri '%winrar_url%' -OutFile '%winrar_installer%'" rem Check if the download was successful if exist "%winrar_installer%" ( echo "WinRAR successfully downloaded to: %winrar_installer%" rem --- Perform silent installation of WinRAR --- echo "Installing WinRAR silently..." start /wait "" "%winrar_installer%" /S rem --- Check if WinRAR was installed successfully --- if exist "C:\Program Files\WinRAR\WinRAR.exe" ( echo "WinRAR installed successfully." ) else ( echo "WinRAR installation failed." ) ) else ( echo "WinRAR download failed!" ) rem --- Remove the Task Scheduler task after installation --- schtasks /delete /tn "RunWinRARBat" /f echo Task removed successfully. pause