0

My use case is this:

  1. There is an (executable but not EXE) file on the company intranet, which updates very often and I usually (but not always) need to download and store the most up-to-date version before launching it.

  2. The file has a permanent address, which does not change. It is downloadable via https protocol only.

  3. I have a bookmark in Chrome, which I always click to download the file. However I have to always select the download location on my local disk.

Question (please note that this is a single question, just written in 3 points):

  1. Is it possible to store a bookmark in Chrome including the download location?
    And no, it is not my default download location, and yes, I have to keep my Chrome set up so it always ask where to save each file before downloading :)

  2. To avoid the x-y problem, is there any other way to download a file over https protocol to a given location with a single click? (Windows 11)
    The preferable (but not necessarily) solution is out-of-the-box-Windows, without installing any 3rd party product. There is also installed GIT bash on the machine.

  3. A nice bonus would be "download and execute with a single click" :)

Honza Zidek
  • 570
  • 1
  • 4
  • 22
  • Any of the various scripting languages would handle this. Chrome cannot execute a file: numerous safeguards in the browser and the OS actively prevent this. But batch and PowerShell should both be well capable of doing what you want. Look up downloading a file or copying a file from a network location and then look up executing a file. Together these two steps should do what you want. – music2myear Dec 17 '22 at 16:53
  • @music2myear The script solution is obvious, I would be able to write it in bash script. The "and execute" part was not crucial. I was mainly wandering if I can create a bookmark in Chrome which would download a file (this part is easy) to always the same path on my local disk, without always needing to choose the path in the dialog (this is the difficult part). Something like "bookmark stored together with download path". I am happy that Saaru directed me to the Powershell solution, which is native to the host computer. – Honza Zidek Dec 17 '22 at 22:44
  • To download from a bookmark, the bookmark just needs to be to the file itself, not to the page or folder the file is linked or stored on. – music2myear Dec 18 '22 at 03:42
  • @music2myear but this was not my question. The "to the specified location" was the crucial part. – Honza Zidek Dec 19 '22 at 07:26

1 Answers1

1

It is a bit of an XY-problem, so I understand your question as follows:

How can I download and run an executable with a single click?

This can all be achieved using Powershell, which is shipped with Windows.

Download, ...

You can use Invoke-Webrequest as follows:

Invoke-WebRequest -Uri "https://your.company.url/here" -OutFile "C:\path\to\file.exe"

run, ...

Again, in Powershell you can do this using the & operator:

& C:\path\to\file.exe

... in a single click

For this you have to create a shortcut that calls Powershell and points to a script file that has above download and run commands in it:

powershell.exe -command "& 'C:\path\to\script.ps1'"

You might run into execution-policy issues, but for that you can ask a specific question after searching (and showing what you've searched for).

Saaru Lindestøkke
  • 5,515
  • 8
  • 30
  • 48
  • You understand my question perfectly! :) It seems working, just I cannot see any output from the `Invoke-Webrequest` command, there is just a very short flash of something blue and the script continues. So I have no feedback if the download succeeded or not. I tried appending something like ` -UseBasicParsing | Select-Object StatusCode | Write-Output StatusCode` but it does not work. – Honza Zidek Dec 14 '22 at 18:25
  • And again, only a few websearches away: https://stackoverflow.com/q/27320508/1256347 I would highly recommend you use more websearches to find your answers as what you're trying to achieve has been asked/done many times before. – Saaru Lindestøkke Dec 14 '22 at 18:43
  • Thanks, Saaru. I didn't know how to write the websearch properly, I am not familiar with the logic of Windows Powershell. I searched for something like "Invoke-Webrequest show http status" and none of the results told me about the `PassThru` parameter. – Honza Zidek Dec 15 '22 at 00:15