RE watace:
不知道你的命令的输出是单行还是多行,单行的话可以不用for,多行的话就要用到for了。
单行:
G:\Cygwin\home\PythonLee>findstr /i "default" %systemdrive%\boot.ini
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
G:\Cygwin\home\PythonLee>findstr /i "default" %systemdrive%\boot.ini>ko.txt
G:\Cygwin\home\PythonLee>type ko.txt
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
G:\Cygwin\home\PythonLee>set /p var=<ko.txt
G:\Cygwin\home\PythonLee>echo %var%
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
G:\Cygwin\home\PythonLee>
多行:
@echo off&Setlocal EnableDelayedExpansion
set num=1
for /f "delims=" %%a in ('findstr "=" %systemdrive%\boot.ini') do (
set var!num!=%%a
set /a num+=1
)
set var
pause