Advertisement
krishean

extract.bat

Dec 10th, 2014
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.35 KB | None | 0 0
  1. @echo off
  2. rem requires 7-Zip, UnxUtils (wget, md5sum, ln)
  3. rem UnxUtils must be in the PATH environment variable
  4. set "base=%~dp0"
  5. set "sevenzipdir=%ProgramFiles%\7-Zip"
  6. set "installdir=%base%Quake II .NET"
  7. set "demofile=%base%q2-314-demo-x86.exe"
  8. set "pakfile=%base%pak0.pak"
  9. set "msifile=%base%Quake II .NET.msi"
  10. if exist "%sevenzipdir%" (
  11.     rem add 7-Zip to PATH
  12.     set "path=%path%;%sevenzipdir%"
  13. ) else (
  14.     echo.Error: 7-Zip not installed.
  15.     goto end
  16. )
  17. if not exist "%installdir%" (
  18.     mkdir "%installdir%"
  19.     :extractmsi
  20.     if exist "%msifile%" (
  21.         rem extract the files from the msi
  22.         msiexec /a "%msifile%" /qb TARGETDIR="%installdir%"
  23.     ) else (
  24.         rem try to download the necessary file
  25.         rem note: wget command is not standard on windows
  26.         wget "http://www.vertigoprojects.com/Quake2NETDownloads/Quake II .NET.msi"
  27.         if not exist "%msifile%.md5" (
  28.             echo.0be4d6c7f6a20436f59699ce707438f7 *Quake II .NET.msi>"%msifile%.md5"
  29.         )
  30.         rem try to verify the msi
  31.         rem note: md5sum command is not standard on windows
  32.         md5sum -c "%msifile%.md5"
  33.         if "%errorlevel%"=="0" (
  34.             goto extractmsi
  35.         ) else (
  36.             echo.Error: Failed to download Quake II .NET.msi
  37.             if exist "%msifile%" (
  38.                 del /f /q "%msifile%"
  39.             )
  40.             goto end
  41.         )
  42.     )
  43.     :extractpak
  44.     if exist "%demofile%" (
  45.         rem extract the pak file from the demo exe
  46.         rem note: needs 7-Zip installed to do this
  47.         7z e -o"%base%" "%demofile%" "Install\Data\baseq2\pak0.pak"
  48.     ) else (
  49.         rem try to download the necessary file
  50.         rem note: this may take a very long time depending on server load
  51.         wget "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe"
  52.         if not exist "%demofile%.md5" (
  53.             echo.4d1cd4618e80a38db59304132ea0856c  q2-314-demo-x86.exe>"%demofile%.md5"
  54.         )
  55.         rem try to verify demo exe
  56.         md5sum -c "%demofile%.md5"
  57.         if "%errorlevel%"=="0" (
  58.             goto extractpak
  59.         ) else (
  60.             echo.Error: Failed to download q2-314-demo-x86.exe
  61.             if exist "%demofile%" (
  62.                 del /f /q "%demofile%"
  63.             )
  64.             goto end
  65.         )
  66.     )
  67.     if exist "%pakfile%" (
  68.         rem link the pak file in the necessary directories
  69.         rem note: ln command is not standard on windows
  70.         if exist "%installdir%\managed\baseq2" (
  71.             ln "%pakfile%" "%installdir%\managed\baseq2\pak0.pak"
  72.         )
  73.         if exist "%installdir%\native\baseq2" (
  74.             ln "%pakfile%" "%installdir%\native\baseq2\pak0.pak"
  75.         )
  76.     )
  77. )
  78. echo.Done.
  79. :end
  80. pause
  81. @exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement