getting process ID of exe running in Bat File

batch-file, batch-processing, windows

Solution

This will launch an executable and get the PID:

@echo off
for /f "tokens=2 delims==; " %%a in (' wmic process call create "notepad.exe" ^| find "ProcessId" ') do set PID=%%a
echo "%PID%"
pause

Problem

I require the Process id of the "Las2xyz" process that's being run in my bat file. How can i achieve this? I can't use the last RUN ID or the first ID, I need the actual process ID, as there are multiple of these running at any given time and ending at any given time i cannot guessimate it. this is my batch: ``` @echo off @echo off set PATH=C:\Windows\system32;C:\atlass\las2xyz;C:\atlass\las2xyz\bin;C:\atlass\las2xyz\lib set TOP_HOME=%C:\atlass\las2xyz% del dat*.xyz dat*.seg dat*.pat dat*.tmp dat*.txt test.nam las2xyz.exe "[ flightpath 2 out 5 lasformat 1 target 0 FIXCLASS 1 step 20 unit *METRIC* fov 20.0 rollfix 1 sn_number *H68_038-003* lsystem *LIDAR_1* DESTSYS 144 minele -100.00 maxele 6000.00 hoff 0.00 eoff 0.00 noff 0.00 bootnr 13110201 leg 1]" "C:\Users\Developer-One\Desktop\las2xyz_Data\131102_003243_GPE.sdc" , "\\192.168.0.102\agis\Macquarie_Barwon_1310\Area_01\sbet_038_13110201.out" - "131102_003243_cov" ``` Someone show me how to do it! thank you

Original source

Related problems