How to get the output of “wmic process call create”

前端 未结 2 1326
[愿得一人]
[愿得一人] 2021-01-20 08:25

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:

w         


        
2条回答
  •  醉话见心
    2021-01-20 09:03

    I just found how can it be done. Due to the command was working only directly in the command prompt I decided to use cmd /c "...", it's as follows:

    for /f "usebackq delims==; tokens=1,2" %i in (`cmd /c "wmic process call create 'notepad.exe a.txt','d:\'"^|findstr ProcessId`) do @echo pid = %j
    

    Now the only thing is that the PID needs to be trimed out of spaces, but that something else. Sorry for the inconvinience.

提交回复
热议问题