- 1 year ago
Windows Batch: wget to download Nirsoft tools - leads to corrupt files
When using the wget
command in a Windows batch script to download files, it may not work as expected for binary files, resulting in corrupted files. In such cases, you can try using the curl
command, which often provides better compatibility for binary downloads on Windows. Here's an example of how you can use curl
to download files:
batch@echo off
set "url=https://example.com/file.zip"
set "output=file.zip"
curl -o "%output%" "%url%"
In this example:
- Replace
https://example.com/file.zip
with the URL of the file you want to download. - Replace
file.zip
with the desired name and extension for the downloaded file. - The
-o
option specifies the output file forcurl
. %output%
represents the value of theoutput
variable, which you can modify according to your requirements.
Save the batch script with a .bat
extension and execute it to download the file using curl
. This approach often resolves issues related to corrupted files when downloading binary files on Windows.
Make sure that curl
is installed on your system and accessible from the command prompt or batch script. You can download curl
for Windows from the official website (https://curl.se/windows/).
Additionally, ensure that you have proper network connectivity, and the URL you are trying to download from is correct and accessible.
If you continue to experience issues with corrupted files, consider trying alternative methods or tools, such as PowerShell's Invoke-WebRequest
cmdlet or dedicated download managers, to download the files you need.