Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
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.Example:
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\
CLS
ECHO Start
ECHO -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.
PAUSEREM To check whether source folder exists or not?
GOTO %1:520
%1=TEST1
ECHO %1
Goto :SECPAR:550
%1==test2
ECHO %1
Goto :SECPARECHO Parameter is not correct %1
PAUSE:SECPAR
ECHO Start Second Parameter:ERROR
ECHO Parameter passed is incorrect:END
Note: i don't want to use system variable.
Regards
Nehal

It's not clear.
=====================================
If at first you don't succeed, you're about average.M2

:: 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.

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?

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.

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?regards
Nehal

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.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |