As I made a batch file to update NirSoft tools (https://www.nirsoft.net/) I made a strange experience using wget. First I downloaded a text file with pad links:
wget http://www.nirsoft.net/pad/pad-links.txt --backups=20 --append-output=C:PathUpdateLOGNirsoft%Timestamp%_NirSoft.log
After I used fart (https://github.com/jonshipman/fart-js) to delete rows I do not need from the pad-links.txt file. Also I used that program to change the download links to (https://www.nirsoft.net/utils/) and change the file extensions to ".zip".
fart ".pad-links.txt" "http://www.nirsoft.net/pad" "http://www.nirsoft.net/utils" | tee --append C:PathUpdateLOGNirsoft%Timestamp%_NirSoft.log and
fart ".pad-links.txt" ".xml" ".zip" | tee --append C:PathUpdateLOGNirsoft%Timestamp%_NirSoft.log
After I used
wget --timestamping --input-file=C:PathUtilSuitNirLauncherDownloadpad-links.txt --append-output=C:PathUpdateLOGNirsoft%Timestamp%_NirSoft.log to download the programs. Having a look at the log file I found out that not all programs are stored in this location. Per example WirelessKeyView is stored in (https://www.nirsoft.net/toolsdownload/wirelesskeyview.zip).
Trying to get this file with wget leads to downloaded corrupt files at size of 4kb. The same with cURL und aria2. When I download it with Mozilla or IDM I have no problems to get the file. So I tried out
wget --auth-no-challenge or
wget --header="Accept: text/html" --user-agent="Mozilla/5.0 ..."
I also tried cliget, the wget/aria2/curl lines it produced while normal downloading with Mozilla.
wget --header 'Host: www.nirsoft.net' --user-agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' --header 'Accept-Language: de,en-US;q=0.7,en;q=0.3' --referer 'https://www.nirsoft.net/utils/wirelesskeyview.html' --header 'Upgrade-Insecure-Requests: 1' --header 'Sec-Fetch-Dest: document' --header 'Sec-Fetch-Mode: navigate' --header 'Sec-Fetch-Site: same-origin' --header 'Sec-Fetch-User: ?1' --header 'DNT: 1' --header 'Sec-GPC: 1' 'https://www.nirsoft.net/toolsdownload/wirelesskeyview.zip' --output-document 'wirelesskeyview.zip'
I googled and found this reference for powershell (same error): Downloading certain files using powershell produce corrupt files but cannot reproduce the working answer in batch (I am not familiar with powershell scripting). So how is is possible to download the single wirelesskey.zip file with wget/curl or aria2 in a batch script? A workaround I found out is downloading it directly from the pad Panel https://www.nirsoft.net/panel/wirelesskeyview.exe but I want the .zip-file including the updated .chm-file and also the 64-bit versions, if available. One more note, within my anti-virus tool the nirsoft site is exempted from scanning, so that is not the answer. Any solutions?
Source: Windows Questions