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 5983385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:13:22+00:00 2026-05-22T22:13:22+00:00

How do I display the value associated with switch A and switch B regardless

  • 0

How do I display the value associated with switch A and switch B regardless of the order in which A and B was specified?

Consider the following call to batch file ParamTest.cmd:

C:\Paramtest.cmd \A valueA \B valueB

Here’s the contents of C:\Paramtest.cmd:

ECHO Param1=%1
ECHO Param2=%2

ECHO Param3=%3
ECHO Param4=%4

Output:

Param1=\A 
Param2=valueA
Param3=\B
Param4=valueB

I would like to be able to identify TWO values passed by their switch names, A and B, regardless of teh order in which these switches were passed

For example, if I execute the following call:

C:\Paramtest.cmd \B valueB \A valueA

I would like to be able to display

A=ValueA
B=ValueB

..and have the same output even if I called the batch file with the param order switched:

C:\Paramtest.cmd \A valueA \B valueB

How do I do this?

  • 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-22T22:13:22+00:00Added an answer on May 22, 2026 at 10:13 pm

    In short, you need to define a loop and process the parameters in pairs.

    I typically process the parameter list using an approach that involves labels & GOTOs, as well as SHIFTs, basically like this:

    …
    SET ArgA=default for A
    SET ArgB=default for B
    
    :loop
    IF [%1] == [] GOTO continue
    IF [%1] == [/A] …
    IF [%1] == [/B] …
    SHIFT & GOTO loop
    
    :continue
    …
    

    It is also possible to process parameters using the %* mask and the FOR loop, like this:

    …
    SET ArgA=default for A
    SET ArgB=default for B
    
    FOR %%p IN (%*) DO (
      IF [%%p] == [/A] …
      IF [%%p] == [/B] …
    )
    …
    

    But it’s a bit more difficult for your case, because you need to process the arguments in pairs. The first method is more flexible, in my opinion.

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

Sidebar

Related Questions

I would like to display HashMap keys and its associated value in the JSF
If I want to display an underlined value in a TextBlock, I have to
In my Windows XP Task Manager, some processes display a higher value in the
Given a specific DateTime value, how do I display relative time, like: 2 hours
I need to format a decimal value into a string where I always display
Does anybody know if there is a way to display the text value of
I'm trying to display the associated forums inside a category during a loop in
I am attempting to display a list of users based on a month value.
My data is such that I want to display values for the Employee and
I have a page with several controls. The controls are bound to display values

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.