This question already has answers here:
How to pass more than 9 parameters to batch file
(11 answers)
How do you utilize more than 9 arguments when calling a label in a CMD batch-script?
(6 answers)
Closed 24 days ago.
I need to send 11 variables to a .BAT
Powershell.exe -executionpolicy remotesigned -File C:\CrLocal\LegajosTemp\Shell.ps1 %1 %2 %3 %4 %5 %6 %7 %8 %9 %10% %11%
But in the %10 and %11 take %1
how can i solve tihs?
Related
I am trying to call a batch file that runs a for loop and calls a second script:
for /f "usebackq" %%i in (`dir/b /o:d %partionHome%\tmp\queue\*.t~#`) do %partitionHome%\conf\SQLLoader\SQL_Loader_%DSNname%\Script.bat %1 %2 %3 %4 %5 %6 %7 %%i %has_prefix% %partionHome%
Script.bat never runs; I've tried adding do call but i believe this gets ignored with FOR /F, I just cannot get the loop to call the script. All parameters are available and paths etc. are correct?
The DIR command is probably not returning anything, so there is nothing for FOR /F to iterate.
Looks to me like you have a spelling mistake: %partionHome% vs. %partitionHome%.
Also, make sure your variables partitionHome and DSNname are defined properly.
The CALL is definitely needed (once you fix the other problems)
Lastly, you should enclose your paths in quotes, just in case there are spaces and/or poison characters within the value.
for /f "usebackq" %%i in (`dir/b /o:d "%partitionHome%\tmp\queue\*.t~#"`) do call "%partitionHome%\conf\SQLLoader\SQL_Loader_%DSNname%\Script.bat" %1 %2 %3 %4 %5 %6 %7 "%%I" %has_prefix% "%partitionHome%"
A few years back I remember using a set command that would take a variable separated by spaces that would assign each value to %1 %2 %3 etc
I read a line from a file which has the following structure
"log file" "B:\Current\log" "B:\Backup\warehouse" "Warehouse_Day"
and assign it to a variable lets say params, then do the infamous set command params, and then automagically I could use each parameter independently.
If I did echo %1, I would get log file
if I did echo %2, I would get B:\Current\log
if I did echo %3, I would get B:\Backup\warehouse
Does anyone remember or know what the command was?
When I understand you right, this is what you think of:
#echo off
set /p "params="<params.bat
echo %params%
call :program %params%
echo %1, %2, %3, %4 are gone.
echo --%param4%--
goto :eof
:program
echo %1
echo %2
echo %3
echo %4
set param4=%4
Of course the %n parametes are only valid within the called subroutine and are gone, when you return from the subroutine (but you can derive other variables from them).
If you need to get rid of the quotes, use %~1, %~2 and so on.
i dont get it. I would like to pass multiple parameters to a batch file, that has the following description:
When passing parameters instead the first parameter (%1) should be PARAM and the
other parameters are shown in the list.
%epin% or %1 contains the file with full path and no extensions for input files
%epout% or %2 contains the file with full path and no extensions for output files
%epinext% or %3 contains the extension of the file selected from the EP-Launch
program. Could be imf or idf -- having this parameter ensures that the correct user
selected file will be used in the run.
%epwthr% or %4 contains the file with full path and extension for the weather file
%eptype% or %5 contains either "EP" or "NONE" to indicate if a weather file is used
%pausing% or %6 contains Y if pause should occur between major portions of
batch file
%maxcol% or %7 contains "250" if limited to 250 columns otherwise contains
"nolimit" if unlimited (used when calling readVarsESO)
%convESO% or %8 contains Y if convertESOMTR program should be called
%procCSV% or %9 contains Y if csvProc program should be called
%cntActv% or %10 contains the count of other simulations active or about to be
active
%multithrd% or %11 contains N if multithreading should be disabled
All i want is to pass parameters %1, %2, %3, %4 and %5... the rest should not be set...
Can somebody please tell me how this works? I searched the web and tried for hours but i won`t get this.
Thanks and greets!
It looks to me like the author of this batch file allows you to use it in 2 different ways,
Option 1
Just pass the parameters on the command line,
file.bat Param1 Param2 Param3 .....
Option 2
set the variables listed and then call the batch file with the single parameter that is exactly PARAM.
SET epin=Param1
SET epout=Param2
...
file.bat PARAM
what is the problem with ?:
set "epin=%~dpfn1"
set "epout=%~dpfn2"
set "epinext=%~3"
if /I not .%epinext% equ .imf (
if /I not .%epinext% equ .idf (
echo wrong extension
exit /b 1
)
)
set "epwthr=%%~dpfnx4"
set "eptype=%%~5"
use a short batchfile (in fact it is very short: one line) (you could name it "DoFile.bat")
#file.bat %1 %2 %3 %4 %5 Y "250" Y Y 3 N
It takes 5 parameters and starts the wanted batch with the full amount of 11 parameters.
It might be neccessary to adapt it a little bit to the needs of file.bat
(no errorhandling included)
I'm trying to call a windows cmd script that runs ant with a variable number of parameters and redirect the output to a logfile. The reason why I call the script that runs ant is because then I ant returns the control the my calling script in which I can proceed with other stuff. My call fails on the redirect at the end, it looks like the redirect is seen as a parameter.
The call look like this:
call ant_call ant -buildfile %BUILDDIR%\cadis\cm\build.xml -Dcvs.tag=%1 deploy_cmdscripts >> %LOGFILE% 2>&1
Since I have an unknown number of parameters the ant script looks like this
%1 %2 %3 %4 %5 %6 %7 %8 %9
Is there an easy way to solve this?
Use %* instead of %1 %2 %3 %4 %5 %6 %7 %8 %9.
%* contains all parameters from the command line, even more than nine.
I need to add logging to a batch file to know what parameters were passed to it.
So if the batch file is run.bat, I have tried adding the line
ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9 >> run.log
Which just echoes the parameters and the string >> run.log.
I suspect you have an unclosed quote somewhere in your parameter list (e.g. foo.cmd "bar would cause that behaviour). You can likely solve this by putting the redirection in front of the echo (yes, this works):
>> run.log echo %*