Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a batch file, do I have to do (e.g.) the following?

@echo off
call other.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
share|improve this question
Similar to $@ on Unix – An̲̳̳drew Oct 21 '10 at 21:05
up vote 7 down vote accepted

Windows batch files (since Windows XP, but possibly earlier) support the %* construct, which evaluates to all the parameters from %1 onwards.

Unfortunately, this doesn't honour the SHIFT command, so the following won't work:

@echo off
set EATEN=%1

call other.bat %*

It'll still pass the first parameter on to the second batch file.

share|improve this answer

You can gather all the args together using something like:

set args=%1
if [%1] == [] goto done
set args=%args% %1
goto start

(use %args% here)

This works regardless of how many arguments there are.

share|improve this answer

If you want to skip the first 3 parameters, for example, and pass on the rest:

@echo off
for /f "tokens=1-3*" %%a in ("%*") do (
   set par1=%%a
   set par2=%%b
   set par3=%%c
   set therest=%%d

call other.bat %therest%

There may be problems with quotes in parameters.

kudos to Patrick Cuff,

share|improve this answer

Yes they do.

You can write your example as follows:

@echo off
call other.bat %*

Also: shift is supported on windows... See this.
But indeed, that last link confirms that shift doesn't work in combination with %*:

• Using %* with shift
  Shift has no affect on the %* batch parameter.

share|improve this answer
Sorry links were bad... should be fixed now. – fretje Jun 9 '09 at 10:06
(quote)Using %* with shift Shift has no affect on the %* batch parameter.(/quote) – Wedge Jun 9 '09 at 10:08
Why the downvote? The question was about %* not about shift. – fretje Jun 9 '09 at 10:13
Your first answer only had "Yes they do" which wasn't an obvious link (or answer). Your last edit is much more of a decent answer, perhaps that's why... – thijs Jun 9 '09 at 11:01
Actually the downvote happened after i added more explanation. And I agree that the link on "Yes they do" wasn't obvious, but it was an exact answer to the question at hand... – fretje Jun 9 '09 at 11:28
@echo off
setlocal enabledelayedexpansion

:: Disable the display of information by changing [set "_ENABLE_INFO="] to [set "_ENABLE_INFO=::"].
set _DBQ="

set "_PARMS.ORIGINAL=%*" && if defined _PARMS.ORIGINAL (
   if not defined _PARMS.IDX (
      echo Parameter Index^(es^) to extract eg.:
      echo 1 2 5 9 11 39 400
      set /p "_PARMS.IDX=>"
   set "_PARMS.IDX=¡!_PARMS.IDX: =¡ ¡!¡"
   set "_PARMS.IDX=!_PARMS.IDX:¡¡=!"
   set "_PARMS.IDX=!_PARMS.IDX: =!"
   call :_FN_PROC.STRING %*
   goto :eof
) else (
   echo No input parameters.
goto :eof

set /a _PARMS.COUNT+=1
for /f "tokens=1* delims= " %%a in ("!_PARMS.PROCESS.STRING!") do (
   set _PARMS.TMP.CHECK=%%a
      for /f "tokens=1* delims=¡" %%c in ("%%a !_PARMS.PROCESS.STRING!") do (
         set _PARMS.TMP.CHECK="%%c"
         set _PARMS.PROCESS.STRING=%%d

) else (


set _DBQ=
goto :eof

echo _PARMS.IDX ^:
echo    ¡^=¡ no Parameter Index was specified for extraction.
echo    ¡n¡ nth Parameter was not processed (Index larger than Parameters Count).
echo    [n] nth Parameter was Extracted.
echo    {n} nth Parameter was Ignored (Remaining).
set _
goto :eof
share|improve this answer
Preserves all special delimiters. Supports as many Parameters as can be fitted in an 8175 character per command line limit (including batch filename, CRLF and batch path if specified). Parameters can be grouped with double quotes (eg. "sw1=/quiet /skip:1 /start=3"). Note: Double quotes are preserved. Behaviour of double quotes are expected (even if used incorrectly, eg. used only singly or " " or ""). Please debug the code first before making a bug report. – Dharma Leonardi May 18 '11 at 7:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.