gpt4 book ai didi

windows - 启动程序并获取进程ID

转载 作者:可可西里 更新时间:2023-11-01 11:15:52 25 4
gpt4 key购买 nike

在批处理文件中,我可以通过以下方式启动与当前 session 并行的程序

start "" notepad.exe

但我需要了解我已经开始的流程。我怎样才能得到它?

最佳答案

@echo off

:: set your own command here
set "command=notepad"
set "workdir=."

set "ReturnValue="
set "ProcessId="
for /f " skip=5 eol=} tokens=* delims=" %%a in ('wmic process call create "%command%"^,"%workdir%"') do (
for /f "tokens=1,3 delims=; " %%c in ("%%a") do (
set "%%c=%%d"
)
)



if not %ReturnValue%==0 (
echo some kind of error - error code %ReturnValue%
) else if defined ProcessId echo PID -^> %ProcessId%

此行删除for /f "tokens=1,3 delims=; "应该是 for /f "tokens=1,3 delims=;<tab><space>"而且我不知道该选项卡是否会正确复制。您还需要检查您的编辑器是否将选项卡替换为空格。另请检查 this .

关于windows - 启动程序并获取进程ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46182585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com