brno
Hi
What is best way to get a PID from task and execute a command and the PID.
Example
i need run test.exe (PID OF TASK), but if PID change i have to run test.exe all the time when PID Change. What i tried was to make a BAT:
Code: Select all
tasklist > a.txt
FINDSTR "taskname.exe" a.txt > b.txt
Someone who can make something like this and can code some hard things contact i have some big prize to you
Thanks
----------------------------
#2 28 Feb 2013 23:40
npocmaka
What you with changed PID?
If PID is changed then the process has been stopped and started again...
----------------------------
#3 01 Mar 2013 00:10
brno
Yes
Thats my problem, IF process stoped and restart PID changed ,the i have to open test.exe with new PID every time the process is closed and reopened.. I need something to check if PID is the same in X minutes, and if change get the new PID and run test.exe with new PID
----------------------------
#4 01 Mar 2013 00:19
npocmaka
Code: Select all
for /f "tokens=1,2" %%P in('tasklist ^| find "test.exe"') do (
set pid1=%%Q
)
:loop
for /f "tokens=1,2" %%P in('tasklist ^| find "test.exe"') do (
set pid2=%%Q
)
if "%pid1%" NEQ "%pid2%" (
set pid1=pid2
*do someting with test.exe*
)
sleep 100
goto :loop