windows - Batch scripting, mutlple finds and multple do sets -


at moment running following information 'systeminfo', needs run systeminfo twice takes time. how able multple 'find"xxx" sets'?

for /f "delims=" %%a in ('systeminfo ^| find "os name"') set "vara=%%a" /f "delims=" %%a in ('systeminfo ^| find "bios version"') set "varb=%%a"  

any appreciated.

next code snippet work (note set commands merely echoed debugging purposes; remove capitalized echo no sooner debugged):

for /f "delims=" %%a in ('systeminfo') (    /f "delims=" %%g in ('echo %%a ^| find /i "os name"') echo set "vara=%%a"    /f "delims=" %%g in ('echo %%a ^| find /i "bios version"') echo set "varb=%%a"  ) 

however, follow stephan's advice , parse wmic output rather (do not forget /value option). correctly, note great dave benham's article wmic , for /f: fix trailing <cr> problem


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -