Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:55:43+00:00 2026-05-17T02:55:43+00:00

In my .bat file, how can I check if wget or curl are available

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:55:44+00:00Added an answer on May 17, 2026 at 2:55 am

    If you know the path where you’d expect to find the EXE, it’s fairly easy:

    IF EXIST C:\Windows\wget.exe ( *** do something with it ***)
    

    …of course you could do IF NOT EXIST with a blurb to copy it, or use an ELSE statement.

    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):

    @echo off
    SETLOCAL
    (set WF=)
    (set TARGET=wget.exe)
    
    :: Look for file in the current directory
    
      for %%a in ("" %PATHEXT:;= %) do (
         if not defined WF if exist "%TARGET%%%~a" set WF=%CD%\%TARGET%%%~a)
    
    :: Look for file in the PATH
    
      for %%a in ("" %PATHEXT:;= %) do (
         if not defined WF for %%g in ("%TARGET%%%~a") do (
            if exist "%%~$PATH:g" set WF=%%~$PATH:g))
    
    :: Results
      if defined WF (
        *** do something with it here ***
      ) else (
        echo The file: "%~1" was not found
      ) 
    

    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, then call :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:

    wget -q <TARGET_URL>
    IF NOT ERRORLEVEL 0 (
      curl <TARGET_URL>
      IF NOT ERRORLEVEL 0 (
        ECHO Download failed!
        EXIT 1
      )
    )
    :: now continue on with your script...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if I can execute some programs for different cmd's using .bat file.
A windows batch file ( called.bat or called.cmd ) can be called from another
I'd like to write a .bat file that can run same .exe file multiple
Is there a command I can put into a Windows XP .bat file to
Instead of using a .bat file, how the code can be built for java
Can anyone tell me how to execute a .bat file from a PHP script?
I can run a bat file in java, I can also get it to
How can I program a bat file that would be capable of putting file.dll
Can one bat file be included in another? I have variables set in one
I need a DOS command or a batch (.bat) file I can execute to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.