在同一批处理文件中,获取刚刚启动的程序的进程ID

时间:2014-05-26 23:43:19

标签: python batch-file wmic

在批处理文件中,我正在调用python脚本,然后我想获取刚刚启动的进程的进程ID。我正在使用这样的东西:

@start /b pythonw pycpoint.py %* >../pycpoint.log 2>&1 
@start /b wmic process where "CommandLine like 'pythonw%%pycpoint%%'" get ProcessID > winPID.txt

但是,永远不会创建winPID.txt文件。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我在终端中启动python,然后打开另一个终端并使用pgrep:

ps -ef | pgrep python

这是你需要的吗? (或python ID:os.getpid()