Windows: single-line command to download and install software

I noted that users of Linux and OSX are sometimes greeted with a very nice feature. Sites like Bowery present on the front page a nice command line code that downloads their software and gets it running immediately.

This is great, however, this was the code provided for Windows:

curl -O && sudo unzip -d /usr/local/bin

If you're a Windows developer, you likely notice the above code gets stuck right on the first part of the code simply because "curl" is a command that is not available by default on Windows.

How can this work under Windows?

I was curious and decided to find a way of doing the same thing using only internal Windows commands. Took some digging but discovered bitsadmin to be a somewhat equivalent tool for this task.

And the one-line command that can be run from a Windows command prompt is:
bitsadmin /transfer t %temp%\x.bat&%temp%\x.bat

What does this code do?

bitsadmin is great because it comes inside any Windows machine since 2000 and above. There is a drawback, it is considerably slow. The first line of command will download a batch script and run this batch from the temporary folder.

The first action by the batch script is to create the needed folders (at c:\triplecheck) and then download wget.exe as the default downloader. This is a single and small sized executable that will speed-up the download process.

Then, we get the software. I didn't had much time to implement a way of extracting zip files under Windows from the command line and so decided to use the default cabinet archive format (.cab) for all packaging. My software runs on Java so I've added some checks to verify if there was Java available on the machine or simply download the Java runtimes from my own server.

At this point must say that the independence of Java tastes really great. Just download, unpack and Java is available. After all these steps are done, the script will download a shortcut that I created earlier and places this shortcut on the user desktop for his convenience when launching the tool.

Everything is finished by opening an Explorer window on the newly created folder and starting up the tool.

The full script code can be found at

What are the advantages?

On my case this provides a one-line command to automatically download and deploy my software on Windows. It is lightning fast, if you already have Java installed then the whole process gets concluded in some 10 seconds on my machine and this is something impressive.


I'm using wget.exe and this will be a problem for certain Anti-virus which might not enjoy the fact that a downloader executable gets inside the system. A possible improvement is checking if wget.exe was in fact permitted to stay on the end-user's folder. If it was removed, then revert to bitsadmin as default downloader.

This bitsadmin tool is marked as deprecated, this is actually something that I don't find so often in the Windows world. Very surprised (and disappointed) to read the message. It seems that from Windows 2000 to Windows 8 machines will be possible to run this tool.

Does not run on Windows RT. The installation script does not take into consideration the newish tablets with Windows RT. Therefore the Java runtimes will not work on devices with an ARM processor. The script could be improved but not so many folks use WinRT for this kind of work.

Cabinet files are used, instead of standard zip files. It is possible to later improve this script for enabling the built-in Windows zip extraction but this wasn't something readily available. The drawback is having two maintain two different sets of archives when distributing my software.

Hope you find this useful.

No comments:

Post a Comment