Reputation: 2035
In my BAT file, i want to read these data from .txt file and need to set each data into one variable
SQLUserName=MFiles
WrapperSQLServerName=usa.com
WrapperDatabase=Wrapper
WrapperAssemblyLocation=D:\Assembly
MFilesNetworkAddress=USA-S1
MFilesVaultName=MF2
MFilesUsername=User
MFilesPassword=
MFilesVaultGUID={26F30-E120-408C-8035-04D85D6}
MFilesWebServerURL=www.WebServer.com
SQLMailProfileName=NoReply
WrapperSupportEmail=thejus@WebServer.com
I tried with this code
FOR /F "tokens=2 delims==" %%a IN ('find "WrapperSupportEmail" ^<config.txt') DO SET SupportEmail=%%a
But it throws error
find is not recognized as an internal or external command operable program or batch file
Please help me
Thejus T V
Upvotes: 0
Views: 3818
Reputation: 2035
My code is correct one only. Only issue is windows cant locate find.exe. I included the .exe on same location and after that everything works fine.
Its working fine in Win 7 and Win 10 without adding Find.exe
Upvotes: 0
Reputation: 56228
when two members with high reputation tell you it works, then it shouldn't be the worst of all ideas to at least try it.
rem @echo off
for /f "delims=" %%i in (config.txt) do set _%%i
pause
set _
I REM
d the @echo off
, so you can watch, how every single line get's processed.
(Your original error find is not recognized ...
is probably because you messed up your %path%
-variable, but you don't need find
for this task.)
Upvotes: 0
Reputation: 537
If the schema of your input file is fixed (keyword=value) and you want to assign all values to an environment variabel named keyword it is very, very easy. try this:
for /f "tokens=1,2 delims==" %i in (config.txt) do set %i=%j
remember to change %i and %j to %%i and %%j if you want to put this call into a cmd-file.
Upvotes: 3