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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:45:11+00:00 2026-06-09T19:45:11+00:00

I am completeley new with windows batch scripting. I want to write a batch

  • 0

I am completeley new with windows batch scripting. I want to write a batch script that gets commandline parameters as below;

myscript -parameter1 param1 -parameter2 param2

It should set parameter1 to param1 and parameter2 to param2 inside the script.
Does anybody have a code block which does the above?

Thanks

  • 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-09T19:45:13+00:00Added an answer on June 9, 2026 at 7:45 pm

    You can go through the arguments with a loop and try something like this:

    :argloop
      set "arg=%~1"
      if "%arg:~0,1%"=="-" (
        set "%arg:~1%=%~2"
        shift
      )
      shift
    if not "%1"=="" goto argloop
    
    echo parameter 1: %parameter1%
    echo parameter 2: %parameter2%
    

    This will look at the arguments one by one and if an argument starts with a - it will set an environment variable of the same name with the next argument as its value:

    H:\>args.cmd -parameter1 param1 -parameter2 param2
    parameter 1: param1
    parameter 2: param2
    

    If you need the original arguments later, then you should move above loop to a subroutine and call it with %* as arguments.

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

Sidebar

Related Questions

We have a scripting engine (running under Windows) that launches another application several thousand
I want to do the below two tasks In Windows Phone 7 application. 1.Navigate
I am completely new in windows phone app development. I want to know what
Okay, I'm completely new to this. I created a python script that imports tkinter
I am completely new to Jena/TDB. All I want to do is to load
I'm new to Python completely and am using Python 3.1 on Windows (pywin). I
I have a windows forms application that runs two threads simultaneously, with the UI
I am completely new developer at Windows Phone 7. I have TextBlock Text={Binding MyDate}
I am completely new to python. I have installed it on windows. I am
I am an inexperienced programmer , completely new to programming for windows . I

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.