Answer the question
In order to leave comments, you need to log in
How to write the output of the Find command to a variable in a bat script?
For example, the command Tasklist |Find /I /c "cmd.exe"
Here, the Find command searches the list of processes for the number of lines with the word "cmd.exe" and displays as a number
C:\Users\UserName\Desktop>TaskList | Find /I /c "cmd.exe"
2
Answer the question
In order to leave comments, you need to log in
Maybe there are more beautiful solutions, but here's the first thing that came to mind - it works ...
@echo off
::Результат пишем во временный файл
TaskList | Find /I /c "cmd.exe" >tmp.txt
::читаем из файла в нашу переменую
for /F %%i in (tmp.txt) do set result=%%i
::используем ее далее
echo Found: %result%
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question