install waterfox.cmd 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. @echo off
  2. @chcp 65001
  3. setlocal enableextensions enabledelayedexpansion
  4. set SRCDIR=%~1
  5. if not defined SRCDIR set SRCDIR=%~dp0
  6. set "PROFILEDIR=%APPDATA%\Mozilla\Firefox\Profiles\"
  7. set FILEMASKS="\Waterfox.*.exe$"
  8. for /f "usebackq tokens=* delims=" %%I in ( `dir /b /s /a:-d "%SRCDIR%\*" 2^>NUL ^| findstr /I "%FILEMASKS%" 2^>NUL` ) do (
  9. set INSTALLER="%%I"
  10. set INSTALLER_EXENAME="%%~nxI"
  11. set INSTALLER_PATH="%%~dpI"
  12. )
  13. if not exist "%INSTALLER%" (
  14. @echo.Загружаю установщик...
  15. for /f tokens^=2^ delims^=^" %%I in ( 'curl.exe -s -L "https://www.waterfoxproject.org/downloads" 2^>NUL ^| findstr /i "Setup.*exe.*\<\/a\>" 2^>NUL' ) do (
  16. set URI=%%~I
  17. set INSTALLER=%%~nxI
  18. set INSTALLER_EXENAME=%%~nxI
  19. )
  20. set INSTALLER_PATH=%SRCDIR%
  21. set "INSTALLER=!SRCDIR!!INSTALLER:%%20= !"
  22. set "INSTALLER_EXENAME=!INSTALLER_EXENAME:%%20= !"
  23. if "!URI!" neq "" ( start "" /b /w curl.exe "!URI!" -o "!INSTALLER_EXENAME!" ) else ( @echo.Cсылка на инсталлятор не найдена )
  24. )
  25. @echo.
  26. @echo.Устанавливаю Waterfox !INSTALLER!
  27. if exist "%INSTALLER%" ( start "" /b /w "%INSTALLER%" -ms ) else ( @echo.Инсталлятор не найден в директории %SRCDIR%&goto:eof )
  28. if exist "%ProgramFiles%\Waterfox\Waterfox.exe" ( start "" /b /w "%ProgramFiles%\Waterfox\Waterfox.exe" -CreateProfile "%UserName%" )
  29. for /f "usebackq tokens=* delims=" %%I in ( `dir /b %PROFILEDIR%\ 2^>NUL ^| find /I "%USERNAME%" 2^>NUL` ) do (
  30. set "PROFILENAME=%%I"
  31. )
  32. @echo.
  33. @echo.Профиль пользователя создан: !PROFILEDIR!!PROFILENAME!
  34. if exist "%INSTALLER_PATH%\prefs.js" copy "%INSTALLER_PATH%\prefs.js" "!PROFILEDIR!!PROFILENAME!\"
  35. if exist "%INSTALLER_PATH%\userContent.css" copy "%INSTALLER_PATH%\userContent.css" "!PROFILEDIR!!PROFILENAME!\chrome\"
  36. if !ERRORLEVEL! NEQ 0 ( @echo.Выполнение прервано. Ошибка:!errorlevel! )
  37. echo.&goto:eof