passing parameters to bat file as 1 string -


it seems simple. in bat file, call program takes command line parameters have parms 1 string, have tried "" around , not sees 1 parm (if guess hit space)

so question how can pass string, parameter list actual string below , must formated such "" etc

-u romeirj -p abc123 -f c:\inetpub\wwwroot\russ\crexport\russ.rpt -o c:\inetpub\wwwroot\russ\russ.pdf -a "startdate: 01-01-2010" -a "gender:m" -a "type:pendjud" 

would call bat file looks like

batfile.bat parmstring 

bat file content

program.exe %1 

as long of batch parameters supposed passed program, can call batch parameters have specified them, , use following within batch script.

program.exe %* 

the problem becomes more complicated if want pass of batch parameters called program.

unfortunately there no method escape quotes within quoted string. impossible escape parameter delimiters. impossible simultaneously embed both spaces , quotes within single batch parameter.

the shift command can strip off leading parameters, %* expands original parameter list; ignores prior shift operations.

the /f not ignore quoted delimiters, doesn't help.

the simple can parse quoted parameter lists, expands * , ? characters using file system. can problem.

the thing left use goto loop combined shift build string containing desired parameters.

suppose first 3 parameters strictly batch file, , remaining parameters passed called program.

@echo off setlocal  set "args=" :buildprogramargs if [%4]==[] goto :argscomplete set args=%args% %4 shift /4 goto :buildprogramargs  :argscomplete program.exe %args%  ::args %1 %2 , %3 still available batch use 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -