0

I have a wget command that I need to run inside a .bat file, as follows:

wget --load-cookies C:\Users\Misharin\Desktop\Nasa\.urs_cookies --save-cookies C:\Users\Misharin\Desktop\Nasa\.urs_cookies --keep-session-cookies --content-disposition --user="xxxxxxxxxx" --password="edu985%&A78" -i C:\Users\Misharin\Desktop\Nasa\Links.txt`

If I open the command prompt and paste the command, it will run just fine and start the download of the links inside the .txt file.

But If I create a .bat file with this command inside of it, when I try to run it will be broken: enter image description here

It says that the URL is missing because the URL file path got broken. As you can see, some characters after the % (from the password) are missing on the command it reads from the .bat file. I'm guessing it is because of the % character itself.

I've tried to research cmd syntax but couldn't find a way out of it. Even tried to use an escape char as referenced at https://ss64.com/nt/syntax-esc.html

Does anyone have any idea how I fix this .bat with that given command without the need for me to change that password?

Note: If I enter a fake password only with alphanumeric chars, the .bat will work just fine too.

  • 1
    In short: While using isolated `%` instances _verbatim_ usually works fine in _interactive_ `cmd.exe` sessions, in _batch files_ you must escape them as `%%`. See the linked duplicate for details. – mklement0 Mar 21 '22 at 02:05

0 Answers0