Is there a way to jump over a section of code in a for loop?
Here is my for loop:
Code: Select all
SET "PREP=Start"
SET "US06=HCT_ACT_06"
SET "US07=HCT_ACT_07"
SET "US08=HCT_ACT_08"
SET "UK09=HCT_ACT_09"
SET "EU10=HCT_ACT_10_PD"
SET "USHFM=HCT_ACT_HFM_0608"
SET "ENTITY_ALL=%US06%$%US07%$%US08%$%UK09%$%EU10%$%USHFM%"
::-- Invoke VB Script Usage Details --::
::-- cscript <VB Script Name> "Argument0" "Argument1" "Argument2" "Argument3" "Argument4" Argument5"
::-- Argument0 = HC_EXCEL_PREPPATH --::
::-- Argument1 = HC_EXCEL_SUBPATH --::
::-- Argument2 = HC_TEMP_UTIL_WB --::
::-- Argument3 = HC_UTIL_WB --::
::-- Argument4 = HC_ACT_ABBREV --::
::-- Argument5 = HC_Utility Tab --::
::-- Argument6 = Excel File .Ext --::
::-- All arguments are passed to the VB Script dynamically - no changes are required to VB Script ever --::
SET "NF5="
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%H IN ( %PREP% %ENTITY_ALL% ) DO (
CLS
CSCRIPT %HC_SF_VBS% "%HC_EXCEL_PREPPATH%" "%HC_EXCEL_SUBPATH%" "%HC_TEMP_UTIL_WB%" "%HC_UTIL_WB%" "%HC_ACT_ABBREV%_%%H.%EXT%" %%H .%EXT% && (
IF "%%H"=="Start" ECHO Completed ^: Prepare Main Utility File >>"%LOGFILE%"
IF "%%H" NEQ "Start" (
ECHO Completed ^: Create Headcount Submission File^(s^)>>"%LOGFILE%"
)
) || (
IF "%%H"=="Start" (
ECHO Failed ^: Prepare Main Utility File >>"%LOGFILE%"
SET "NF5=T"& GOTO AbnormalExit
) ELSE (
ECHO Failed ^: Create Headcount Submission File^(s^)>>"%LOGFILE%"
SET "NF5=T"& GOTO AbnormalExit
)
)
PING -n 2 127.0.0.1>nul
)
However, based on a if check, I need to jump over the main peice of code in the for loop if false.
For instance, this is how I want to write it:
Code: Select all
FOR %%H IN ( %PREP% %ENTITY_ALL% ) DO (
FOR %%E IN ( %ENTITY_ALL:$= % ) DO (
IF %%E==%K09% GOTO SKIP
IF %%E==%K09% GOTO SKIP
)
CLS
CSCRIPT %HC_SF_VBS% "%HC_EXCEL_PREPPATH%" "%HC_EXCEL_SUBPATH%" "%HC_TEMP_UTIL_WB%" "%HC_UTIL_WB%" "%HC_ACT_ABBREV%_%%H.%EXT%" %%H .%EXT% && (
IF "%%H"=="Start" ECHO Completed ^: Prepare Main Utility File >>"%LOGFILE%"
IF "%%H" NEQ "Start" (
ECHO Completed ^: Create Headcount Submission File^(s^)>>"%LOGFILE%"
)
) || (
IF "%%H"=="Start" (
ECHO Failed ^: Prepare Main Utility File >>"%LOGFILE%"
SET "NF5=T"& GOTO AbnormalExit
) ELSE (
ECHO Failed ^: Create Headcount Submission File^(s^)>>"%LOGFILE%"
SET "NF5=T"& GOTO AbnormalExit
)
)
PING -n 2 127.0.0.1>nul
:SKIP
)
But it doesn't seem to be working. Am I doing anything wrong or is this the wrong approach?