Batch newbie here. I have an issue with a variable not being captured correctly. I have SCCM Object variable's for ABC_RegionCode, ABC_DBNAME, ABC_Schema and srvpocWeb_%%% (where %%% equals one of 100's of regioncodes).
My Question: How can i get this batch to pull the variable value for srvPocWeb_(ABC_RegionCode) if the Regioncode variable changes for each machine it runs on? I need the script to know that srvPocWeb_%1="%4" means i want the value of the variable to be stored in %4.
this script works fine if i just hardcode the full sitecode name rather than srvPocWeb_%1="%4". its almost as if batch cannot tell i want this translated to a string before reading it.
example.bat %ABC_RegionCode% %ABC_DBNAME% %ABC_SCHEMA% !srvPocWeb_%1! >> C:\test.txt
@echo off
Setlocal EnableDelayedExpansion
Rem Pull in variables from SCCM OBject -
@echo set ABC_RegionCode="%1"
@echo set ABC_DBNAME="%2"
@echo set ABC_SCHEMA="%3"
@echo set srvPocWeb_%1="%4"
@echo "C:\Program Files\Application_%1\Database\Tools\Client\Client.exe" sourcepath="C:\Source" databasetype="oracle" databaseconnection="data Source=%2;User Id=%3;Password=!srvPocWeb_%1!" reportsfolderpath="C:\reports"
@echo "C:\Program Files\Application_%1\Database\Tools\Client\Client.exe" sourcepath="C:\Source" reImportBuild=true outputonly=false databasetype="oracle" databaseconnection="data Source=%2;User Id=%3;Password=!srvPocWeb_%1!" reportsfolderpath="C:\reports"
@echo All Done
editfacility under the tags to edit this data into your question - and remember to disguise the data supplied if appropriate.