cmd - Set undefined variables in a batch file FOR loop -


in batch file arbitrary number of variables listed, defined, others not. how can set undefined (not set value) variables names starting "_" 1 in loop or iterative way?

the code below prints defined variables starting "_" (underscore), doesn't set undefined variables 1.

@echo off setlocal enableextensions enabledelayedexpansion  :variables set "_a=good" & set "_b=" & set "c=" & set "d=6" & set "_e=bad" set "_f=" & set "_g=ugly"  :core /f "tokens=1,2 delims==" %%i in ('set _') (     if "%%j"=="" set "%%i=1"     echo %%i %%j)  /f "tokens=1,2 delims==" %%i in ('set _') (     set "varn=%%i" & set "varp=%%j"     if not %%j equ 1 (echo %%i = %%j     ) else (set /p "%%j=enter %%i > " 2>nul) ) call :verify !varn! !varp!      exit /b  :verify rem more code 

@echo off setlocal enableextensions enabledelayedexpansion  :variables set "_a=good" & set "_b=" & set "c=" & set "d=6" & set "_e=bad" set "_f=" & set "_g=ugly"  :allvariables rem must define here list "all variables" set "variables=_a _b c d _e _f _g"  :core %%v in (%variables%) if not defined %%v set "%%v=1" exit /b 

below :allvariables label must define variables want, question did not defined such method! may collect parameters, or line in text file, or...


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -