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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:42:16+00:00 2026-06-04T10:42:16+00:00

I am sending various parameters to batch file. In that i need the parameter

  • 0

I am sending various parameters to batch file. In that i need the parameter next to the “-l” ..

For example : when calling the .bat

Test.bat sampl.exe -s ssss -m mmmm -l path -k kkkk -d dddd

In this i need to extact “path” based on the presence of -l. In general, I need to extract the next parameter to “-l”. Is there a way i could do it ? Please help

  • 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-04T10:42:17+00:00Added an answer on June 4, 2026 at 10:42 am

    The idea is to loop through the list of parameters and if -l is found then call another section that then extracts the next parameter.

    The SHIFT, removes the first parameter from the list of available parameters. eg:

    If you ran: sampl.exe -s ssss -m mmmm -l path -k kkkk -d dddd

    The available parameters would be = -s ssss -m mmmm -l path -k kkkk -d dddd\

    If in the script you executed SHIFT, then the available parameters would be = ssss -m mmmm -l path -k kkkk -d dddd

    See the code example below:

    @ECHO OFF
    
    SET path=
    SET mmm=
    SET sss=
    SET ddd=
    
    REM Loop through passed parameters
    :LOOP
    IF [%1]==[] GOTO LOOP_END
        IF [%1]==[-s] @CALL :PROCESS_S %2
        IF [%1]==[-m] @CALL :PROCESS_M %2
        IF [%1]==[-l] @CALL :PROCESS_L %2
        IF [%1]==[-d] @CALL :PROCESS_D %2
        SHIFT
    GOTO LOOP
    :LOOP_END
    
    
    REM call your actual end result here.. Once the batch file gets here, the variable path would have been set if there was a -l <my path> passed, otherwise it would be empty
    cd %path%
    runmyprogram.exe %sss% %mmm% %ddd%  
    
    GOTO:EOF
    
    
    REM Define your methods down here.
    :PROCESS_S
        IF [%1]==[] GOTO:EOF
        SET sss=%1
        SHIFT
        GOTO:EOF
    
    :PROCESS_M
        IF [%1]==[] GOTO:EOF
        SET mmm=%1
        SHIFT
        GOTO:EOF
    
    :PROCESS_L
        IF [%1]==[] GOTO:EOF
        SET path=%1
        SHIFT
        GOTO:EOF
    
    :PROCESS_D
        IF [%1]==[] GOTO:EOF
        SET ddd=%1
        SHIFT
        GOTO:EOF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several different c# worker applications that run various continuous tasks: sending emails
I need to include basic file-sending and file-receiving routines in my program, and it
I build various web applications in PHP. Clients usually have the need for sending
I have a PHP file that handles sending out confirmation emails. I also have
For sending the same message to 100 devices via c2dm, We need to do
When sending HTML e-mail, I understand that it's a best practice to send a
How can I perform various task (such as email alert/sending news letter) on a
I have found various topics here and elsewhere on creating an intent for sending
I've been working with sending and receiving email through various web-mail clients using WatiN,
Just looking at various ways of ftp'ing a file in c#. I noticed some

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.