In my .bat file, how can I check if wget or curl are available in the system through whatever other previous installations the user may have went through. Is this check possible, and can I have if then else logic in my file to react differently, like we do in normal programming. I basically want to use wget or curl to download a file.
If (wget is available)
do something
else if (curl is available)
do something else
else
tell the user they are out of luck
If you know the path where you’d expect to find the EXE, it’s fairly easy:
…of course you could do
IF NOT EXISTwith a blurb to copy it, or use anELSEstatement.Otherwise, if you don’t know where you might find the file, you can search for it with something like this (original source found here):
You could wrap that whole block into a function and call it once for each EXE (change the
%TARGET%s back into%~1, give it a :TITLE, thencall :TITLE wget.exe)…Alternately, you could take a different approach and just try the commands and see if they fail. Since ERRORLEVEL of 0 usually means success, you could do something like this: