Monitoring EXE File Version Updates at a Static URL

asheroto
4 min readSep 22, 2023
Preview of the script

NOTE: See my new project, Chocolatey-Package-Updater for a PowerShell-only solution.

Tracking version changes in executable files can be challenging, especially when software developers use a static URL for each new release. This issue became apparent to me during my time maintaining Chocolatey packages. New versions would roll out, checksums would differ, and the package would fail, often prompting someone to notify me since there was no other way to be alerted.

Monitoring release notes or changelogs can be useful, and tools like VisualPing.io are generally good for that. However, there are exceptions, such as ClickUp, where this approach falls short. ClickUp maintains a consistent URL for all versions, and their release notes may not necessarily correspond to changes in the desktop client.

For managing version updates in Chocolatey, AU is a commonly used tool. However, AU hasn’t been updated since October 2022 and has some functional limitations. For this specific Chocolatey project, I ended up writing a PowerShell script instead of using Puppeteer to monitor filename version changes, however, I am keeping this Gist up in case anyone is interested in the JS/Puppeteer/Apify approach.

The JavaScript code that follows was created before I finished my PowerShell script. The JS/Puppetteer/Apify approach is particularly useful if you don’t have your machine running continuously for scheduled scripts. Leveraging Apify’s free service with the script below allows you to track changes without needing your computer to be always on.

See how the URL will be the same for each version? Argh!

To tackle this, I developed a tool in JavaScript that leverages Puppeteer to initiate a headless Chrome browser. The tool navigates to the download link, examines the Content-Disposition header to find the filename, extracts the version number, and compares it against a version stored in an environment variable. If there's a discrepancy, it triggers a GET request to send an alert.

The notification is handled by a basic script on my web server, which sends an email. The tool can be easily customized to your liking-you could configure it to send Discord messages, text messages, and more. I’ve built this tool with Apify.com, which offers some usage for free and supports integrations with platforms like Zapier. This makes it a viable option if you don’t have your own web server or hosting solution.

The script is intended to run on a schedule, whether cron, Task Scheduler, or a service like Apify. It makes use of the puppeteer-extra-plugin-stealth package to avoid issues with anti-bot measures such as with Cloudflare.

How it works

  • Launches a new Puppeteer page
  • Navigates to the URL of the file you want to check, which is set as an environment variable
  • Listens for the response event to capture headers
  • Retrieves the filename from the Content-Disposition header
  • Uses a regular expression to extract the version number from the filename
  • Compares the version number to the current version number, which is set as an environment variable
  • If the retrieved version number is greater than the current version number, it navigates to a secret page to send an alert

How to use

  • Set the CURRENT_VERSION environment variable to the current version number you want to compare against
  • Set the FILE_URL environment variable to the URL of the file you want to check
  • Set the SECRET_URL environment variable to the URL of the secret page you want to send an alert to
  • Adjust the line that uses the SECRET_URL variable as needed-the URL provided is just an example method of sending an alert, you can of course use any method you want
  • Set the NOTIFICATION_API_KEY environment variable to the API key for the secret page
  • Update the CURRENT_VERSION environment each time the version changes to prevent it from re-alerting you

You can find this script on the GitHub Gist:

https://gist.github.com/asheroto/056000ef898ffd0a84beee784e031aec

Hope you find this useful!

Consider becoming a Medium member if you appreciate reading stories like this and want to help me as a writer. It costs $5 per month and gives you unlimited access to Medium content. I’ll get a little commission if you sign up via my link.

--

--

asheroto

🌎 Full Stack Developer 🔗 Systems Administrator 😎Innovation through Automation ✔ Privacy Advocate ♥ Startup Facilitator