[Batch] WGet batch GUI

Discussion in 'Scripting' started by Humphrey, May 22, 2013.

  1. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    982
    60
    #1 Humphrey, May 22, 2013
    Last edited by a moderator: Apr 20, 2017
    I was working on a GUI for WGet and thought I would post it here for the communities support.

    I would like to simplify these WGet batch files.
    I will post updates when I have wrote and tested them and i encourage others to point out problems or even help write the code.
    Anyone is welcome to use these batches.

    To Do:

    Create WGET menu for adding/subtracting options such as whether or not to read robots.txt, continue downloads, set user agent (or enter custom one), etc.
    Multiple instance downloading.
    List of downloads available direct download such as digitalriver/microsoft/etc. (If some/all links are not allowed, please notify me.)
    Wrap the GUI and WGet in a exe and distribute.

    Get WGet here: http://gnuwin32.sourceforge.net/packages/wget.htm


    Code:
    @ECHO OFF
    
    REM Prerequisites
    
    REM Set/Create download location
    SET dwnloc="%HomePath%\Downloads\WgetDownload"
    IF NOT EXIST "%dwnloc%" mkdir "%dwnloc%"
    IF NOT EXIST "%dwnloc%\2007" mkdir "%dwnloc%\2007"
    IF NOT EXIST "%dwnloc%\2010" mkdir "%dwnloc%\2010"
    IF NOT EXIST "%dwnloc%\Win7" mkdir "%dwnloc%\Win7"
    IF NOT EXIST "%dwnloc%\Win7\x86" mkdir "%dwnloc%\Win7\x86"
    IF NOT EXIST "%dwnloc%\Win7\x64" mkdir "%dwnloc%\Win7\x64"
    
    TITLE WGET Downloader
    
    REM Change CMD color to Registry Value
    setlocal ENABLEEXTENSIONS
    set cmdcolork=HKCU\Software\Microsoft\Command Processor
    set cmdcolorv=DefaultColor
    for /F "usebackq tokens=2 delims=x" %%A IN (`reg query "%cmdcolork%" /v "%cmdcolorv%" 2^>nul ^| find "%cmdcolorv%"`) do (
      IF /I %%A EQU 0x0 (GOTO MAINMENU) ELSE (Color %%A)
    )
    
    REM Locate Program Files folder for WGET (Needs improvment)
    IF EXIST "C:\Program Files (x86)\GnuWin32\bin" (
        set wget="C:\Program Files (x86)\GnuWin32\bin\wget.exe"
    ) ELSE (
        set wget="C:\Program Files\GnuWin32\bin\wget.exe"
    )
    IF NOT EXIST %wget% Echo WGET NOT FOUND! & PAUSE && EXIT
    
    
    REM SEND TO HALT !NEEDS WORK!
    IF NOT EXIST %WGET% CLS & EXIT
    GOTO MAINMENU
    REM Stops batch opertations for a important announcment.
    :HALT
    ECHO.
    ECHO. WGET hasn't been located in its default directories
    ECHO. in the x86/x64 Program Files folder, if it is
    ECHO. installed somewhere else, drag and drop the exe
    ECHO. into this window and press enter.
    ECHO. REMOVE THE QUOTATION MARKS!
    ECHO. Other wise type WGET to download it.
    ECHO.
    SET /p wget=Drag WGET.EXE here: 
    IF /i "%wget%"=="wget" CLS & Start http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe & EXIT
    SET WGET="%WGET% -c"
    
    REM Main Menu
    :MAINMENU
    ECHO.
    ECHO.  /- This batch contains English language files only -\
    ECHO.
    ECHO. A) Microsoft Office (x86 Only)
    ECHO. B) Microsoft Windows (x64/x86)
    ECHO. C) Remember to verify the hashes!
    ECHO.
    ECHO. D) Exit
    ECHO.
    choice /C ABCD /N /M  "Select one of the options above (A-D):"
    IF %ERRORLEVEL% EQU 1 CLS & GOTO OFFICE
    IF %ERRORLEVEL% EQU 2 CLS & GOTO Windows
    IF %ERRORLEVEL% EQU 3 CLS & Start http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx & CLS & GOTO MAINMENU
    REM Friendly Exit - Won't close CMD Prompt if Bat exicuted from one.
    IF %ERRORLEVEL% EQU 4 CLS & EXIT /B
    
    
    
    REM Office Menu
    :OFFICE
    TITLE Microsoft Office
    ECHO.
    ECHO. A) Microsoft Office 2007
    ECHO. B) Microsoft Office 2010
    ECHO. C) Microsoft Office 2013 ^(OFFLINE^)
    ECHO.
    ECHO. D) Main Menu
    ECHO.
    choice /C ABCD /N /M  "Select one of the options above (A-D):"
    IF %ERRORLEVEL% EQU 1 CLS & GOTO 2007
    IF %ERRORLEVEL% EQU 2 CLS & GOTO 2010
    IF %ERRORLEVEL% EQU 3 CLS & GOTO 2013
    IF %ERRORLEVEL% EQU 4 CLS & GOTO MAINMENU
    
    REM Office 2007 menu
    :2007
    TITLE Office 2007
    ECHO.
    ECHO. A) Original Releases (SP0)
    ECHO. B) Service Packs (1-3)
    ECHO. C) Activation ^(OFFLINE^)
    ECHO.
    choice /C ABC /N /M  "Select one of the options above (A-C):"
    IF %ERRORLEVEL% EQU 1 CLS & GOTO 20071
    IF %ERRORLEVEL% EQU 2 CLS & GOTO 20072
    IF %ERRORLEVEL% EQU 3 CLS & GOTO 20073
    
    REM Original Releases
    :20071
    TITLE Editions
    ECHO.
    ECHO. A) Home ^& Student (X12-30107)
    ECHO. B) Standard (X12-30263)
    ECHO. C) Small Business (X12-30283)
    ECHO. D) Professional (X12-30196)
    ECHO. E) Ultimate (X12-30307)
    ECHO.
    ECHO. F) Main Menu
    ECHO.
    choice /C ABCDEF /N /M "Select one of the options above (A-F):"
    IF %ERRORLEVEL% EQU 6 CLS & GOTO MAINMENU
    IF %ERRORLEVEL% EQU 5 %wget% -O "%dwnloc%\2007\X12-30307.exe" "http://msft-dnl.digitalrivercontent.net/msoffice/pub/X12-30307/X12-30307.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 4 %wget% -O "%dwnloc%\2007\X12-30196.exe" "http://msft-dnl.digitalrivercontent.net/msoffice/pub/X12-30196/X12-30196.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 3 %wget% -O "%dwnloc%\2007\X12-30283.exe" "http://msft-dnl.digitalrivercontent.net/msoffice/pub/X12-30283/X12-30283.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 2 %wget% -O "%dwnloc%\2007\X12-30263.exe" "http://msft-dnl.digitalrivercontent.net/msoffice/pub/X12-30263/X12-30263.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 1 %wget% -O "%dwnloc%\2007\X12-30107.exe" "http://msft-dnl.digitalrivercontent.net/msoffice/pub/X12-30107/X12-30107.exe" & GOTO 2007
    
    
    :20072
    TITLE Office 2007 Service Packs
    ECHO.
    ECHO. A) Service Pack 1
    ECHO. B) Service Pack 2
    ECHO. C) Service Pack 3
    ECHO.
    ECHO. D) Main Menu
    ECHO.
    choice /C ABCD /N /M "Select one of the options above (A-D):"
    IF %ERRORLEVEL% EQU 1 %wget% -O "%dwnloc%\2007\office2007sp1-kb936982-fullfile-en-us.exe" "http://download.microsoft.com/download/0/8/1/08186057-e110-49fb-b455-17899cf082d8/office2007sp1-kb936982-fullfile-en-us.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 2 %wget% -O "%dwnloc%\2007\office2007sp2-kb953195-fullfile-en-us.exe" "http://download.microsoft.com/download/A/1/4/A14E308D-529C-48F9-9DAF-7C3BDC88FA57/office2007sp2-kb953195-fullfile-en-us.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 3 %wget% -O "%dwnloc%\2007\office2007sp3-kb2526086-fullfile-en-us.exe" "http://download.microsoft.com/download/2/2/A/22AA9422-C45D-46FA-808F-179A1BEBB2A7/office2007sp3-kb2526086-fullfile-en-us.exe" & GOTO 2007
    IF %ERRORLEVEL% EQU 4 GOTO MAINMENU
    
    REM Unpacked in temp folder.
    :20073
    EXIT
    
    :2010
    TITLE Office 2010
    ECHO.
    ECHO. A) Home ^& Student  (Key Dependant)
    ECHO.    Home ^& Business (Key Dependant)
    ECHO.    Professional    (Key Dependant)
    ECHO. B) Standard
    ECHO. C) Professional Plus
    ECHO.
    ECHO. D) Activation
    ECHo.
    ECHO. E) Main Menu
    ECHO.
    choice /C ABCDE /N /M "Select one of the options above (A-E):"
    IF %ERRORLEVEL% EQU 1 %wget% -O "%dwnloc%\2010\X17-75058.exe" "http://msft.digitalrivercontent.net/office2010/X17-75058.exe" & GOTO OFFICE
    IF %ERRORLEVEL% EQU 2 %wget% -O "%dwnloc%\2010\X17-75575.exe" "http://msft.digitalrivercontent.net/office2010/X17-75575.exe" & GOTO OFFICE
    IF %ERRORLEVEL% EQU 3 %wget% -O "%dwnloc%\2010\X17-75238.exe" "http://msft.digitalrivercontent.net/office2010/X17-75238.exe" & GOTO OFFICE
    IF %ERRORLEVEL% EQU 4 CLS & START http://forums.mydigitallife.net/threads/28669-Microsoft-Toolkit-Official-KMS-Solution-for-Microsoft-Products
    IF %ERRORLEVEL% EQU 5 GOTO MAINMENU
    
    
    
    :2013
    Title Office 2013 (Office 365)
    Office 2013 Professional Plus x86
    http://azcdn01.digitalrivercontent.net/office2010/X18-65189.iso
    Office 2013 Language Pack x86
    http://azcdn01.digitalrivercontent.net/office2010/X18-51530.exe
    Office Project 2013 Professional x86
    http://azcdn01.digitalrivercontent.net/office2010/X18-65375.exe
    Visio 2013 Professional x86
    http://azcdn01.digitalrivercontent.net/office2010/X18-65443.exe
    
    
    :Windows
    TITLE Windows
    ECHO.
    ECHO. A) Windows 7
    ECHO. B) Windows 8 (Offline)
    ECHO.
    ECHO. C) Main Menu
    ECHO.
    choice /C ABC /N /M "Select one of the options above (A-C):"
    IF %ERRORLEVEL% EQU 1 CLS & GOTO Win7
    IF %ERRORLEVEL% EQU 2 CLS & GOTO Win8
    IF %ERRORLEVEL% EQU 3 CLS & GOTO MAINMENU
    
    :Win7
    TITLE Windows 7
    ECHO.
    ECHO. 86-bit Versions
    ECHO.
    ECHO. A) Home Premium x86
    ECHO. B) Professional x86
    ECHO. C) Ultimate x86
    ECHO.
    ECHO. 64-bit Versions
    ECHO.
    ECHO. D) Home Premium x64
    ECHO. E) Professional x64
    ECHO. F) Ultimate x64
    ECHO.
    ECHO. G) Activation
    ECHO.
    ECHO. H) Main Menu
    ECHO.
    CHOICE /C ABCDEFGH /N /M "Select one of the options above (A-H):"
    
    
    IF %ERRORLEVEL% EQU 1 %wget% -O "%dwnloc%\Win7\x86\en_windows_7_home_premium_with_sp1_x86_dvd_u_676701-X17-58996.iso" "http://msft.digitalrivercontent.net/win/X17-58996.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 2 %wget% -O "%dwnloc%\Win7\x86\en_windows_7_professional_with_sp1_x86_dvd_u_677056-X17-59183.iso" "http://msft.digitalrivercontent.net/win/X17-59183.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 3 %wget% -O "%dwnloc%\Win7\x86\en_windows_7_ultimate_with_sp1_x86_dvd_u_677460-X17-59463.iso" "http://msft.digitalrivercontent.net/win/X17-59463.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 4 %wget% -O "%dwnloc%\Win7\x64\en_windows_7_home_premium_with_sp1_x64_dvd_u_676549-X17-58997.iso" "http://msft.digitalrivercontent.net/win/X17-58997.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 5 %wget% -O "%dwnloc%\Win7\x64\en_windows_7_professional_with_sp1_x64_dvd_u_676939-X17-59186.iso" "http://msft.digitalrivercontent.net/win/X17-59186.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 6 %wget% -O "%dwnloc%\Win7\x64\en_windows_7_ultimate_with_sp1_x64_dvd_u_677332-X17-59465.iso" "http://msft.digitalrivercontent.net/win/X17-59465.iso" & GOTO Windows
    IF %ERRORLEVEL% EQU 7 Start http://forums.mydigitallife.net/threads/24901-Windows-Loader-Current-release-information & GOTO Windows
    IF %ERRORLEVEL% EQU 8 GOTO MANIMENU
    
    
    Another version

    Code:
    @ECHO OFF
    Title WGET Downloader
    
    REM Location to download files to. (Current Dir)
    CD /D %~dp0
    
    REM SETs wget locations.
    SET wg="C:\Program Files (x86)\GnuWin32\bin\wget.exe"
    
    REM SETs URL to download from.
    SET url0="http://www.drfsupercenter.info/Windows ISOs/en_windows_vista_with_sp2_x86_dvd_342266.iso"
    SET url1="http://www.drfsupercenter.info/Windows ISOs/en_windows_vista_sp2_x64_dvd_342267.iso"
    SET url2="http://www.drfsupercenter.info/Windows ISOs/en_windows_vista_enterprise_sp2_x86_dvd_342329.iso"
    SET url3="http://www.drfsupercenter.info/Windows ISOs/en_windows_vista_enterprise_sp2_x64_dvd_342332.iso"
    SET url4="http://www.drfsupercenter.info/Windows ISOs/en_windows_xp_home_with_service_pack_3_x86_cd_x14-92413.iso"
    SET url5="http://www.drfsupercenter.info/Windows%20ISOs/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
    SET url6="http://download.microsoft.com/download/3/B/D/3BD9DD65-D3E3-43C3-BB50-0ED850A82AD5/SQLServer2012SP1-FullSlipstream-ENU-x64.iso"
    SET url7="http://download.microsoft.com/download/3/B/D/3BD9DD65-D3E3-43C3-BB50-0ED850A82AD5/SQLServer2012SP1-FullSlipstream-ENU-x86.iso"
    SET url8="http://download.microsoft.com/download/0/4/C/04C805CC-4C04-4D76-BE80-7D67B951CF73/waik_supplement_en-us.iso"
    
    REM SET referal link.
    SET ref="http://www.drfsupercenter.info/"
    
    REM SET the user agent.
    SET uagent="-U Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
    
    REM Logging and Debug
    SET lode=-d -a Log.log
    
    REM Robots?
    SET norob=-e robots=off
    
    REM Mirror a website
    SET mir=-r -nc -c
    
    REM Wget command line
    %WG% %norob% %mir% %url0%
    %WG% %norob% %mir% %url1%
    %WG% %norob% %mir% %url2%
    %WG% %norob% %mir% %url3%
    %WG% %norob% %mir% %url4%
    %WG% %norob% %mir% %url5%
    %WG% %norob% %mir% %url6%
    %WG% %norob% %mir% %url7%
    %WG% %norob% %mir% %url8%
    
    REM STOP
    PAUSE
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...