Skip to content

Instantly share code, notes, and snippets.

@bhrgu
Created October 30, 2017 14:18
Show Gist options
  • Save bhrgu/9c258cc26fab82560ae9a29548706eb6 to your computer and use it in GitHub Desktop.
Save bhrgu/9c258cc26fab82560ae9a29548706eb6 to your computer and use it in GitHub Desktop.
Read key-value config file with good old cmd :)
@ECHO OFF
SET CONFIGFILE=config.txt
REM Create the key-value config file
ECHO #Simple key-value config > %CONFIGFILE%
ECHO Key1=Value1 >> %CONFIGFILE%
ECHO Key2=Value2 >> %CONFIGFILE%
REM Read keys and setting values
FOR /F "eol=# delims== tokens=1,2" %%i IN (%CONFIGFILE%) DO SET %%i=%%j
REM Show varibales
SET Key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment