Answer the question
In order to leave comments, you need to log in
How to output the result of a cmd command to a variable?
Hello colleagues.
There is a batch file containing the following command:
net user %username% | findstr /C:"Password expires" >tmp.txt
But there is a task to output this result not to a temporary file, but to a variable.
Google found some solution, but it doesn't work:
FOR /F "delims=" %i IN ('net user %username% ^| findstr /C:"Password ends"') DO set var=%i
Either I'm wrong I see.
Help me to understand.
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question