Is there a way to do this purely in a .bat file?
The purpose is to launch iexplore.exe
, then kill just that instance when it\'s finished.
A slight variation on the answer provided by @kybernetikos since it has a parsing issue. Note the line if %%j gr 0 (
@echo off
rem there is a tab in the file at the end of the line below
set tab=
set cmd=javaw -jar lib\MyProg.jar
set dir=%~dp0
echo Starting MyProg
set pid=notfound
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "%cmd%"^, "%dir%"`
) do (
if %%j gtr 0 (
set pid=%%j
)
)
echo %pid% > MyProg.pid