I'm trying to get the output of wmic process call create
so I can get the ProcessId
of the newly created process. If I just run:
wmic process call create "notepad.exe a.txt","d:\"
It works just fine (it opens the file a.txt
under folder d:\
with notepad
). Now, if I try:
for /f "usebackq delims==; tokens=1,2" %i in (`wmic process call create "notepad.exe a.txt","d:\"^|findstr ProcessId`) do @echo pid = %j
It doesn't, and shows me the error:
Formato incorrecto. Sugerencia: <lista_parámetros> = <parámetro> [, <lista_parámetros>].
I don't really know what's going on here, can anyone explain this to me or if this is possible at all?
NOTE: Other commands work fine. For instance, if I run:
for /f "usebackq" %i in (`wmic process where "executablepath like '%%notepad.exe'" get ProcessId /value^|findstr ProcessId`) do @echo OUTPUT: %i
It gives the expected output, which in this case is:
OUTPUT: ProcessId=2084
Thanks!