How to replace input parameter of batch file

June 22, 2009 at 01:40:51
Specs: Windows XP

I have a batch file which has 2 input argument.
This batch file calls another vbscript where again 2 parameter needs to be passed. This parameter is modified value of the one that are passed to batch file.

I have different version of application i.e. 110, 120, 130, 200,210,220 etc.
I have batch file test.bat and vbscript as test.exe.
(1) Run batch file 'test 130 210'
(2) convert this 130 = v1_30 and 210 = v2_10.
If my arguments were 200 and 220 then v2_00 and v2_20
(3) Run vbscript as 'test.exe v1_30 v2_10'.

Note: 'v?_??' is the path of code and i don't want to enter this as argument.
If above is not clear kindly let me know.

I tried below but no success
@echo off
REM xcopy c:\RTVideo\* c:\RTvideo1\
ECHO Start

ECHO You are about to execute 520 build
ECHO ----
ECHO Want to Continue? If not than Press Ctrl + C, Y and Enter. Else only Enter.

REM To check whether source folder exists or not?



ECHO Parameter is not correct %1

ECHO Start Second Parameter

ECHO Parameter passed is incorrect


Note: i don't want to use system variable.


See More: How to replace input parameter of batch file

Report •

June 22, 2009 at 02:01:34
It's not clear.

If at first you don't succeed, you're about average.


Report •

June 22, 2009 at 02:11:34
:: TEST.BAT Usage: test  Argument1 Argument2
@echo off & setlocal
set param1=%1
set param1=V%param1:~0,1%_%param1:~1,2%

set param2=%2
set param2=V%param2:~0,1%_%param2:~1,2%

start "" test.exe %param1%  %param2%
:: Emd_Of_Batch

Example: test 130 200.

Do not store test.bat and test.exe in the same directory otherwise test.bat will never run as the extension of executables follows the precedence rule COM, EXE, BAT.

Better you rename test.bat e.g. mytest.bat or anything else as you like.

Report •

June 22, 2009 at 21:29:06
Thanks for the reply.

As far as possible i don't want to use variable. Main reason is i have to keep this batch file on web server and my administrator may not allow this i.e. use of set variable.

Is there any other way to achieve this?

Report •

Related Solutions

June 23, 2009 at 06:31:33
Unfortunately it is not possible to avoid the use of environment variables as the substring manipulation statement requires that kind of variable.

I want to point out however the environment variables the script sets up are local to its execution according to the specified SETLOCAL directive, i.e. param1 and param2 are not persistent and are restricted to the test's run only.

Report •

June 24, 2009 at 01:36:54
Thanks for the reply.

If variables are local to the script i.e. live till script is running than no problem. (Param1 and param2 should not be displayed on typing SET).

In above case i can use the solution.
Can you please confirm?


Report •

June 24, 2009 at 03:41:29
I do confirm what I posted and you spelled about the local behavior of the variables inside a script holding the SETLOCAL directive.

SETLOCAL is aimed to avoid any hurt to the runnig environment (as to accidentally modify a system variable) and can be used to hide the values too. There is no way to access the variables after the end of the batch as they are phased out.

Report •

Ask Question