0

I need to run "create.exe" for each value in RS_NAME[ ] .

One of the parameters that "create.exe" requires is the FILE_CONFIG[ ] which should correspond to the RS_NAME[ ] --> FILE_CONFIG[0] for RS_NAME[0].

I cannot figure out how to correctly pass the respective FILE_CONFIG[ ] value into CALL command. I tried to use another FOR loop to no avail.

Any help would be appreciated.

Thank you!

SETLOCAL EnableDelayedExpansion
@echo off
...
...
SET RS_NAME[0]=Application1
SET RS_NAME[1]=Application2
SET RS_NAME[2]=
SET RS_NAME[3]=

REM FILE_PARAMS[0] corresponds to RS_NAME[0] and so on.

SET FILE_CONFIG[0]=C:\Users\Administrator\Desktop\Application1Params.xml
SET FILE_CONFIG[1]=C:\Users\Administrator\Desktop\Application2Params.xml
SET FILE_CONFIG[2]=
SET FILE_CONFIG[3]=

For /F "tokens=2 delims==" %%s in ('set RS_NAME[') do ( 

   ::  Displaying all information and writing it to "LOGFILE"
   call %PATH_TO_EXEC%create.exe -action info -user %USER% -pass %PASSWORD% 
   timeout %TIMEOUT% >>%LOGFILE%

   :: Finding "RS_NAME" in the "LOGFILE" and if not present, then create one    
   findstr /m %%s %LOGFILE%
   if !errorlevel!==0 (
    echo ### ------ERROR------### RS_NAME ### %%s ### ALREADY EXISTS
    exit /b
        )
   if !errorlevel!==1 (
       call %PATH_TO_EXEC%create.exe -action create -name %%s -fileconfig 
       %FILE_CONFIG% -version %VERSION% -type %TYPE% -user %USER% -pass 
       %PASSWORD% -timeout %TIMEOUT%
       if !errorlevel! neq 0 (
       echo ### ------ERROR------ ### Failed to create resource: %%s. 
       exit /b !errorlevel! 
       )
       if !errorlevel! equ 0 (
       echo ### ------SUCCESS------ ### Created Successfully 
       )
     )

)
  • 2
    `for /F "tokens=2,3 delims=[]=" %%s in ('set RS_NAME[') do echo File: !FILE_PARAMS[%%s]!, Name: %%t` I suggest you to review [this answer](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990) – Aacini May 03 '19 at 14:26
  • Thank you, Aacini, that was really helpful! – drBerzelius May 03 '19 at 15:57
  • May I ask you to upvote the linked answer? **`;)`** – Aacini May 03 '19 at 18:19
  • @Aacini I did upvote the linked answer, but... "Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score." – drBerzelius May 06 '19 at 09:26

0 Answers0