windows - Manage a process inside a cmd file -


i manage process inside cmd file. cmd launch other cmd file , update status, ... example, write date when other process closed.

so, tried :

rem %process% path cmd file start "process" %process% 

is there way manage started process ?

i tried use :

for /f "tokens=1,2,*" %%a in ('tasklist /fi "imagename eq %process%"') (     set mypid=%%b ) 

the problem process cmd file imagename "cmd.exe".

any solutions ?

it easier pid when starting process. can wmic command (though it's little bit cumbersome):

@echo off  /f "skip=5 tokens=* delims=" %%a in ('wmic process call create "notepad.exe"^,"c:\"') (     /f "tokens=2 delims=;= " %%# in ("%%a") if not defined pid set "pid=%%#" )  echo %pid% 

you can use this ready use script can spare work (hope message descriptive enough)


Comments