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

  • SEARCH
  • Home
  • 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 8940665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:05:46+00:00 2026-06-15T11:05:46+00:00

To check if a command is available in a bash shell, I usually do:

  • 0

To check if a command is available in a bash shell, I usually do:

command -v $COMMAND >/dev/null 2>&1 || {
    echo >&2 "Error: this script requires the command '$COMMAND' to be available"
    exit 1
}

What is the equivalent in Windows?

  • 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-06-15T11:05:47+00:00Added an answer on June 15, 2026 at 11:05 am

    You can use something very similar

    %command% >nul 2>&1 || (
        echo "Error: command not found"
        exit /b 1
    )
    

    Granted, this will actually execute the command, but most commands will do nothing without proper parameters. If you want to be more sure, you can use %command% /? >nul 2&1. This will try to bring the help page for the command, without executing it

    Update:
    To avoid executing the command entirely, consider where.exe. It comes bundled with Vista and Windows 7. For other OSes, you can download it. Please refer to this post on how to download it

    Once you have it, you can run it with /Q switch to avoid extra output. Return code of 0 means command was found. Once thing that I found is that the where command requires you to supply the extension.

    One the other end, there is a lengthy discussion here about a batch “one-liner” that works without an extension specified (but actually fails when you do specify an extension)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to check existing of Character (*,&,$) in Given String using python command
In ksh shell, I wanna to check the return value after running a command,
Currently I have this small script that makes it possible to check if a
I got the following error message when debugging a perl script. dumpvar.pl not available
Since I write a command line program to check cpp files, and it need
Is there anyway to check if a window.history.go command is successful in changing the
Are there equivalent to perl -c syntax check for JavaScript from command? Given that
Assuming an InnoDB table, will the following command ... CHECK TABLE table_name; ... cause
Check this code : HTML : <div style="position: absolute; visibility: visible; width: 172px;"> <img
Check this page. On either firefox, chrome, or IE9 / 10 the tabs on

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.