作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在批处理文件中,我可以通过以下方式启动与当前 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/
我是一名优秀的程序员,十分优秀!