我正在尝试编写.bat文件,以便:
在Windows 10环境中。
就像这样:
start "myProcess" Node/node.exe bin/www
start chrome index.html
我从这里尝试了一切:
Find Process Name by its Process ID
Find a Windows process based on its description, using CMD
Find PID of process that use a port on Windows
我也尝试只使用index.html pid:
@echo off&cls
set current_path=%~dp0
set current_path_modified=%current_path:~0,-1%
set "programname=index.html"
start "%current_path_modified%\%programname%"
for /f "tokens=1" %%a in ('wmic PROCESS where "Name='%programname%'" get ProcessID ^| findstr [0-9]') do set programmepid=%%a
echo %programname% est lance avec le PID %programmepid%
taskkill /im %programname% /f
pause
但是无法打印PID。