Direct link to download latest version
-
Hello Notepad community,
I wanted to know if there was a possibility to access a link that will immediately download the latest version available of Notepad++ as this would be useful for automated deployments on Windows machines without having to script my way through it (too much)
Something in the lines of notepad-plus-plus/downloads/latest would be fine (had to trim the link :D)
Let me know if such solution exist, I briefly looked into it but I can’t currently spend much time on it since this is for work and I have an avalanche of other things to do… Thanks for the help! :D
-
without having to script my way through it (too much)
Depending on what you mean by “too much”, the built-in updater looks at https://notepad-plus-plus.org/update/getDownloadUrl.php?version=8¶m=x64 – will provide an XML like the following:
<GUP> <NeedToBeUpdated>yes</NeedToBeUpdated> <Version>8.7</Version> <Location>https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.7/npp.8.7.Installer.x64.exe</Location> </GUP>
So all you need to do in your script is grep out the URL beteween
<Location>
and</Location>
– so that’s not “too much” scripting.The two parameters that I sent to the URL (after the
?
) are theversion=8
, which claims to the URL that you are asking if you need to update when you only have version 8.0; since we’re at v8.7 already, that’s a safe number to hardcode into the URL you use, because v8.0 will always need upgrading at this point; and theparam=x64
says you want the 64-bit version; if you give no¶m=...
, it will be 32-bit version;param=arm64
will request the arm64 version.Caveat: please note, that as discussed here, and earlier with a post directly from the developer here, the
getDownloadUrl.php
is intended for internal Notepad++ use, and as such can change its format without warning; however, the developer admits the URL cannot be hidden, and so tacitly admits that people can use that URL on their own, as long as they understand that its behavior might change without announcement. -
Thanks for the detailed answer! This is super helpful
And by “too much” I meant that, I’m scripting on Windows and any amount of scripting in MS Batch is too much in my opinion :D But we’re stuck with Windows on that one so I have to make do with what we have
I will see what I can do with Powershell directly, it might be a better option (…probably)
-
@sargonphin said in Direct link to download latest version:
I will see what I can do with Powershell directly, it might be a better option (…probably)
$recentURL = (Invoke-WebRequest "https://notepad-plus-plus.org/update/getDownloadUrl.php?version=8¶m=x64").Content | Select-Xml -XPath "/GUP/Location" | Select-Object -ExpandProperty Node | Select-Object -ExpandProperty InnerText Invoke-WebRequest -Uri $recentURL -OutFile "c:\...\downloads\Notepad++.Recent.Installer.x64.exe"
This only took ~10 minutes for me to figure out – someone who doesn’t use powershell on a regular basis, and was basically just searching the internet to get SO answers and similar for how to do each piece of the puzzle.
-
@sargonphin said in Direct link to download latest version:
… I’m scripting on Windows and any amount of scripting in MS Batch is too much in my opinion :D But we’re stuck with Windows on that one so I have to make do with what we have
Well, you can do it all in MS Batch… I used wget to do the fetch here but using curl would get the same results.
@echo off setlocal set XVER_XML=Notepad++.xml set "XURL=https://notepad-plus-plus.org/update/getDownloadUrl.php?version=8¶m=x64" rem The have_version_xml logic is mainly to help with debugging the parsing logic rem as I did not need to re-download the version XML each time. if exist "%XVER_XML%" goto :have_version_xml wget.exe -O "%XVER_XML%" --no-check-certificate "%XURL%" if errorlevel 1 goto :handle_wget_error :have_version_xml rem We expect the entire XML blob in XLINE to look like this: rem <GUP><NeedToBeUpdated>yes</NeedToBeUpdated><Version>8.7</Version><Location>https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.7/npp.8.7.Installer.x64.exe</Location></GUP> for /f "usebackq delims=" %%i in ("%XVER_XML%") do set "XLINE=%%i" set "XEXPECT=<GUP><NeedToBeUpdated>yes</NeedToBeUpdated><Version>" if not defined XLINE goto :unexpected_content if "%XLINE:~0,52%" NEQ "%XEXPECT%" goto :unexpected_content set "XLINE=%XLINE:~52%" rem Copy one character at a time from XLINE to XVERSION until we hit the trailing </Version><Location> set XVERSION= set "XEXPECT=</Version><Location>" :version_loop if not defined XLINE goto :unexpected_content if "%XLINE:~0,20%" == "%XEXPECT%" goto have_version set "XVERSION=%XVERSION%%XLINE:~0,1%" set "XLINE=%XLINE:~1%" goto :version_loop :have_version echo New Notepad++ Version: %XVERSION% set "XLINE=%XLINE:~20%" rem Copy one character at a time from XLINE to XURL until we hit the </Location></GUP> set XURL= set "XEXPECT=</Location></GUP>" :url_loop if not defined XLINE goto :unexpected_content if "%XLINE%" == "%XEXPECT%" goto have_url set "XURL=%XURL%%XLINE:~0,1%" set "XLINE=%XLINE:~1%" goto :url_loop :have_url echo New Notepad++ URL: %XURL% exit /B 0 goto :eof :handle_wget_error echo. echo Error %ERRORLEVEL% from wget exit /B 1 goto :eof :unexpected_content echo. echo Error, unexpected contents. echo Have: "%XLINE%" echo Expect: "%XEXPECT%" exit /B 2 goto :eof