我有这个窗口的批处理命令:
wmic process call create "notepad.exe" | find "ProcessId"
它返回此字符串
(spaces) ProcessId = 13764;
而且我只需要在变量中存储pid号(13764),我该怎么办?
解决方法
for /F "delims=" %%a in ('wmic process call create "notepad.exe" ^| find "ProcessId"') do ( for %%b in (%%a) do set value=%%b ) echo %value%
此方法返回行中的最后一个单词,因此它也可以在开头的可变数量的单词的其他行中使用.