11

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?

5
  • 3
    "wget/curl results in an error" - Okay. But which error?
    – Panki
    Mar 12, 2020 at 7:46
  • 1
  • 5
    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?
    – ckujau
    Mar 12, 2020 at 8:43
  • Instead of directly using wget/curl you could check what parameters are POSTed is sent and then use the a suitable GET request
    – Vedant
    Mar 12, 2020 at 10:19
  • 1
    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.
    – WGRM
    Apr 29, 2020 at 1:33

3 Answers 3

9

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'
3

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.

1
  • 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.
    – kaiya
    Apr 20, 2021 at 11:48
2

I've made a tool for automating the entire process called Mido:

https://github.com/ElliotKillick/Mido

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .