1.

Solve : Monitoring processes to trigger an action?

Answer»

Hi there,

I am trying to create a relatively simple batch file that opens two applications when run.

This is OK, but the first application needs a login which may take a user between 5 secs and 5 hours!

Therefore, I would like the second application to run after the login has occured. Monitoring system processes I notice a unique programme runs when the login is completed.

Is it POSSIBLE to add a line to the batch file to 'watch' for this programme and then run the next application?

Many thanks in advance for your help.

Regards

PaulQuote from: PaulB on April 08, 2009, 05:11:46 AM

Therefore, I would like the second application to run after the login has occured. Monitoring system processes I notice a unique programme runs when the login is completed.

how do you notice that programme is running?? what the name of it?
post your current batch code here.Hi there,

I notice the programme is running by going to Windows Task Manager and monitoring the processes. After the user has 'logged in' the same process loads. This is called viewserver.exe.

I would like this process to trigger the next stage of the batch file.

ThanksCode: [Select]@echo off
>$$$.vbs echo q="select * from __InstanceCreationEvent within 1 where " ^& _
>>$$$.vbs echo "targetinstance ISA 'win32_process' and targetinstance.name='viewserver.exe'"
>>$$$.vbs echo getobject("winmgmts:").execnotificationquery(q).nextevent

echo First stage of batch file

for %%a in (cscript//nologo del) do %%a $$$.vbs

echo viewserver.exe creation detected
echo next stage of the batch fileHi Reno, That is brillaint, thanks...

I was using the follwowing but got into trouble. I could sometimes see the error level change, but the next programme would not launch, or both would launch without seeing the trigger..........


@echo off
START C:\Programme1
PING 1.1.1.1 -n 1 -w 1000 >NUL
:LOOP1
tasklist>C:\tasklist.txt
cd c:\
FIND "ViewServer.exe" c:\tasklist.txt
PING 1.1.1.1 -n 5 -w 1000 >NUL
echo %errorlevel%
IF %ERRORLEVEL% EQU 1 GOTO LOOP1 ELSE START C:\SEARCH
DEL c:\tasklist.txt

if you want to check errorlevel for find then you must move that if
Code: [Select]@echo off
START C:\Programme1
PING 1.1.1.1 -n 1 -w 1000 >NUL

:LOOP1
PING 1.1.1.1 -n 5 -w 1000 >NUL
tasklist>C:\tasklist.txt
cd c:\

Find "ViewServer.exe" c:\tasklist.txt
IF %ERRORLEVEL% EQU 1 GOTO LOOP1 ELSE START C:\SEARCH

DEL c:\tasklist.txt
that old code was looking for PINGs errorlevel


Discussion

No Comment Found