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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:49:09+00:00 2026-06-15T17:49:09+00:00

Id like to make a batch file that runs a jar X amount of

  • 0

Id like to make a batch file that runs a jar X amount of times from user input. I have looked for how to handle user input, but I am not totally sure.
In this loop I’d like to increase the parameters I am sending to the jar.

As of now, I do not know

  • manipulate the variables in the for loop, numParam, strParam

So, when i run this little bat file from the command line, I get am able to do user input, but once it gets to the for loop, it spits out “The syntax of the command is incorrect

So far I have the following

@echo off

echo Welcome, this will run Lab1.jar
echo Please enter how many times to run the program
:: Set the amount of times to run from user input
set /P numToRun = prompt


set numParam = 10000
set strParam = 10000
:: Start looping here while increasing the jar pars
:: Loop from 0 to numToRun
for /L %%i in (1 1 %numToRun%) do (
    java -jar Lab1.jar %numParam% %strParam%

)
pause
@echo on

Any suggestion would be helpful

Edit:
With the recent change, it doesnt seem to run my jar file. or at least doesnt seem to run my test echo program. It seems that my user input variable is not being set to what I have inputted, it stays at 0

  • 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-15T17:49:10+00:00Added an answer on June 15, 2026 at 5:49 pm

    What happened was for my last issues was something with how the variables expanded. This was actually answer at dreamincode.net: Here

    Final code:

    @echo off
    
    echo Welcome, this will run Lab1.jar
    :: Set the amount of times to run from user input
    set /P numToRun= Please enter how many times to run the program: 
    
    set /a numParam = 1000
    set /a strParam = 1000
    
    setlocal enabledelayedexpansion enableextensions
    
    
    :: Start looping here while increasing the jar pars
    :: Loop from 0 to numToRun
    for /L %%i in (1 1 %numToRun%) do (
        set /a numParam = !numParam! * 2
        set /a strParam = !strParam! * 2
        java -jar Lab1.jar !numParam! !strParam!
    
        :: The two lines below are used for testing
        echo %numParam%  !numParam!
        echo %strParam%  !strParam!
    )
    
    @echo on
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the output of a file that I would like to make a
In a batch file, I have this line that runs an antivirus program. I'd
I was wondering how to make a batch file that runs a certain command/commands
I would like a batch file that can register a user into itself. something
I'm trying to make a batch file that executes a simple command: shutdown -h
I need to modify batch file. I have a batch file that opens many
In my Windows batch file I have a various amount of variables. Lets say
I have about 1000 files like: _etc_sec _home_host_www_temp and etc. How to make batch
I want to make a batch file, that would make me happy a long
I have a windows batch file that does this: for %%s in (*.sql) do

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.