|
Answer» Is there a way by which i can do a piping of command output to a variable instead of file? I require continuing my execution based on the command outputs. I really dont want to create a file while executing my dos commands if it is feasible.
Thanks in advance for the HELP offered.i dont know if PIP cvan do this but u can use this
for /F "delims=" %%i in ('commands') do set r=%%i echo %r%Thanks mate. But how actually can I capture the entire o/p set in the variables, as this would allow me just to store just the last line of my o/p in r.Say what the command is and what specific output you are looking for. Unless you give more information we cannot help you.
We are not mind readers.
u can do that but show us the code so we can help u more setlocal ENABLEDELAYEDEXPANSION set /a con=1 for /f "delims=" %%i in ('commands') do ( set VAR!con!=%%i set /a con=!con!+1 ) endlocal echo %var1% echo %var2% . . . Sorry guys for not being clear in conveying my ask.
I am invoking a executable from my batch script, which outputs multiple lines. Currently am outputting the same to a file. Please find below the code snippet
Code: [Select]call %SYS_DIR%powercfg.exe -L | findstr /C balanced > plan.txt Sample contents of plan.txt would be Code: [Select]Power Scheme GUID: 382a0719-1dcf-45ae-a357-0b9cedfb0f43 (balanced) * Power Scheme GUID: 5d73e9ca-7776-4dc3-8eee-dd828ae4f989 (balanced1) Instead of writing it to a txt file, am interested in storing it in dos variables. Can tat be done ? Yes. .bat_man has told you how to do it. yes it can
setlocal ENABLEDELAYEDEXPANSION set /a con=1 for /f "delims=" %%i in ('^%SYS_DIR^%/powercfg.exe -l ^| findstr /C balanced') do ( set var!con!=%%i set /a con=!con!+1 ) endlocal echo %var1% echo %var2% . . . he has told you twice now.
|