Download Windows ISO from microsoft using wget or curl

14,752

Solution 1

I finally found a solution, and there's no extension necessary in Firefox.

After getting the URL you received, open a new tab in Firefox and open the Developer Tools (F12). Switch to the Network tab and enter the URL for the download. Hit cancel when it prompts you to download.

There will be a GET request now under Network; right-click it and select Copy > Copy as cURL. Paste this massive string into your terminal and add -o [/path/filename] to actually save the file somewhere instead of dumping it to STDOUT. That's it!


In a Chromium based browser, On the Microsoft Download page after it has created the "32-bit Download" and "64-bit Download button". Open the Developer Tools, then switch to the Network tab (it should be empty). click the 32 or 64 bit download button. It should bring up a save as dialog, cancel it. Right mouse click on the new url listed in the Network tab, Copy -> Copy as Curl Then paste it into the terminal windows, and append the -o [/path/filename] value. (ex -o Win10_20H2_v2_English.iso) and it should start downloading.

Solution 2

It is forbidden because there is are special characters in the url that are interpreted by the shell. There is e.g. '?' and '&'. Now take a look on your example url:

curl --location --remote-name https://software-download.microsoft.com/pr/Win10_1909_English_x64.iso?t=77395428-650e-4e5c-8bcc-97abca347eaa&e=1583937294&h=2b05fad63d3a6e2a0c4a20cb49f34e7c

This will:

  1. start a subshell which actually did the following:
curl --location --remote-name https://software-download.microsoft.com/pr/Win10_1909_English_x64.iso?t=77395428-650e-4e5c-8bcc-97abca347eaa
  1. start a subshell where a variable 'e' is assigned the value '1583937294'
  2. In you current shell environment there will be a variable 'h' assigned with the value '2b05fad63d3a6e2a0c4a20cb49f34e7c'

How to fix it? - Simple, just add single quotes around the url:

curl --location --remote-name 'https://software-download.microsoft.com/pr/Win10_1909_English_x64.iso?t=77395428-650e-4e5c-8bcc-97abca347eaa&e=1583937294&h=2b05fad63d3a6e2a0c4a20cb49f34e7c'
Share:
14,752

Related videos on Youtube

Curi0usM3
Author by

Curi0usM3

Updated on September 18, 2022

Comments

  • Curi0usM3
    Curi0usM3 over 1 year

    Objective: download the official Win10_1909 iso into linux directly via command line

    Source: https://www.microsoft.com/en-in/software-download/windows10ISO

    After selecting edition and language you get 64bit links like as follows, valid for 24 hours

    https://software-download.microsoft.com/pr/Win10_1909_English_x64.iso?t=77395428-650e-4e5c-8bcc-97abca347eaa&e=1583937294&h=2b05fad63d3a6e2a0c4a20cb49f34e7c

    This works fine via any gui browser or any platforms, but we need this in a linux box

    • linux server is ofcourse gui less (no intend to install gui)
    • wget/curl results in an forbidden html file download
    • Changing user agent to firefox in wget/curl or adding custom payload as curl -d '{"t": 77e897e2-a32c-419c-8f18-54770dbb5a15,"e": 1583942596,"h": 595f691df8f7e4088d24b6cc37077d1a}' and requesting the .iso file returns a forbidden page
    • tried linux based download managers like aria and axel it fails as well, forbidden

    How to accomplish this via command line only?

    • Admin
      Admin about 4 years
      "wget/curl results in an error" - Okay. But which error?
    • Admin
      Admin about 4 years
    • Admin
      Admin about 4 years
      Did the same as you described, right clicked on the "64-bit Download" button, copy link, wget "https..." -O w.iso (the "" are important) and got a working ISO. But yeah, as @Panki asked: what's the error message? First guess: wget without -O or curl with -O produces a file name too long for your local file system to handle?
    • Admin
      Admin about 4 years
      Instead of directly using wget/curl you could check what parameters are POSTed is sent and then use the a suitable GET request
    • Admin
      Admin about 4 years
      There is an extension for Firefox, "download with wget" or something. You can download with Firefox, abort and get the link with everything needed. For example a cookie for the session.
  • kaiya
    kaiya about 3 years
    Answer is deprecated, terminal download is possible via the link above (if generated fresh via Mircrosoft page), it's just forbidden because of the 24 hours availability. No headers or cookies needed.