Downloading Latest D Language DMD compiler via Windows 10 batch script file.
BoQsc
vaidas.boqsc at gmail.com
Tue Dec 17 16:55:56 UTC 2019
Initialy I though about a way to download DMD compiler on a
single line of command prompt.
However it turned out that dlang website makes downloading the
latest version a complex thing.
Here, I'm sharing a batch script that might be interesting if you
are wondering how to download and launch latest d language
compiler setup in a single click.
Usage: Copy and paste the script below into a text file
and rename the text file to a file name that ends in .cmd or .bat
extension
Examples:
download-dmd.cmd
download-dmd.bat
.cmd and .bat extensions are the same thing, no worries about
that.
>@ECHO OFF
>
>:Download-version-number-file-from-dlang
>:: Downloads LATEST file from dlang, via bitsadmin - official
>command line download utility included since Windows 7
>:: LATEST file is a plain text file that contains a single line
>of text: a number of latest version of DMD. bitsadmin /Transfer
>"%random%" "http://downloads.dlang.org/releases/LATEST"
>"%cd%/LATEST"
>IF NOT ERRORLEVEL 0 (
> TITLE BITSADMIN have an error, retrying to download LATEST file
> TIMEOUT "2"
> CLS
> GOTO :Download-version-number-file-from-dlang )
>:: A hacky Batch language way to store File content inside a
>variable.
>SET /P "version=" < "LATEST"
>
>:: Simply delete LATEST file, we don't need it anymore LATEST
>file is stored inside variable named "version"
>DEL "LATEST"
>CLS
>
>
>:: Get YEARS from from Windows 10 Date Environment Variable
>:: Windows 7 might require adjustments to gather the correct
>years, as the format might be different
>SET "yearsRightNow=%date:~0,4%"
>
>:: Download Latest version of dmd compiler for Windows, via
>bitsadmin
>bitsadmin /Transfer "%random%"
>"http://downloads.dlang.org/releases/%yearsRightNow%/dmd-%version%.exe" "%cd%/dmd-%version%.exe"
>
>:: Launch the downloaded compiler's setup
>start "" "dmd-%version%.exe"
>
>
More information about the Digitalmars-d
mailing list