I have this window's batch command:
wmic process call create "notepad.exe" | find "ProcessId"
It returns this string
(spaces) ProcessId = 13764;
And I need to store in a variable only the pid number (13764), how can I do?
I have this window's batch command:
wmic process call create "notepad.exe" | find "ProcessId"
It returns this string
(spaces) ProcessId = 13764;
And I need to store in a variable only the pid number (13764), how can I do?
for /f "tokens=2 delims=;= " %%P in ('wmic process call create "notepad.exe" ^| find "ProcessId"') do echo %%P
for /F "delims=" %%a in ('wmic process call create "notepad.exe" ^| find "ProcessId"') do (
for %%b in (%%a) do set value=%%b
)
echo %value%
此方法返回该行中的最后一个单词,因此它也可以用于开头的单词数可变的其他行。
for /f "tokens=3 delims=;=" %%a in ("(spaces) ProcessId = 13764;") do set value=%%c
echo %value%
用这个:
echo %strContent:~6, -1%