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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:02:16+00:00 2026-06-11T01:02:16+00:00

In my Windows batch file I have a various amount of variables. Lets say

  • 0

In my Windows batch file I have a various amount of variables. Lets say I have the following variables:

set varTest1=test1
set varTest2=test2
set otherVar=variable500
set varS=string
set yetAnotherVar=foo

They do really make no sense buts thats not the point. I am looking for a method that prints out all values of variables that start with var:
So when I run my batch with a certain help parameter it should print out all three variables starting with var and its value.
The output could look like this:

These are the available variables:
varTest1 : test1
varTest2 : test2
varS : string

I created the following for reading the parameter:

IF "%1" == "" ( 
echo No help parameter was set. Program will exit. ) ELSE ( 
IF "%1" == "help" ( 
call :showAllAvailableVars ) ELSE (
echo Do something else))

Now I would have my method

:showAllAvailableVars

I think the solution could be something with the findstr method but I could not figure it out how to do that because findstr is mainly for files and not for searching through own program variables.

  • 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-11T01:02:18+00:00Added an answer on June 11, 2026 at 1:02 am

    Create array instead of different variables. Like,

    set var[0]=test1
    
    set var[1]=test2
    
    set var[2]=string
    

    then in your ‘showAllAvailableVars’ function do this

    for /L %%i in (1,1,%n%) do echo !var[%%i]!

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

Sidebar

Related Questions

I have a variable define as: set filePath=.\file.txt I'm writing a windows batch file.
In my Windows batch file I have some variable with a various number of
I have a windows batch file in Windows 7 which does something with find.
I have a Windows batch file that processes all the files in a given
I have a windows batch file, which outputs directory path, e.g.: @echo c:\windows I
I have been trying to find a way of getting a windows batch file
Under Windows 7 I have a batch file for checking the status of some
I have a simple batch file sitting in my windows system - @echo off
I have a batch file I'm running from a Windows XP w/service pack 3
I'm running Windows 2003 Service Pack 2. I have a batch file that runs

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.