windows - Start program and get process id -


in batch file can start program in parallel current session via

start "" notepad.exe 

but need handle of process i've started. how can it?

@echo off  :: set own command here set "command=notepad" set "workdir=."  set "returnvalue=" set "processid=" /f " skip=5 eol=} tokens=* delims=" %%a in ('wmic process call create "%command%"^,"%workdir%"') (     /f "tokens=1,3 delims=;  " %%c in ("%%a") (         set "%%c=%%d"     ) )    if not %returnvalue%==0 (     echo kind of error - error code %returnvalue% ) else if defined processid echo pid -^> %processid% 

delims in line for /f "tokens=1,3 delims=; " should for /f "tokens=1,3 delims=;<tab><space>" , don't if tab correctly copied.you need check if editor replaces tab spaces.check this.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -