Page 1 of 2
Close Service if programm is closed
Posted: Thu Oct 18, 2012 9:02 am
by datroubler
What I like to do is that RoboTask checks if an application ( in this case Cisco AnyConnect) is still running (symbol is shown besides the clock) and if it isn't running anymore the service should be shut down. How can i realise that?
Close Service if programm is closed
Posted: Thu Oct 18, 2012 12:24 pm
by Oleg
You can check process existence and do something in compliance with result.
Look at {IsProcessExists()} variable
Usage:
{IsProcessExists(<Program_EXE_File>)}
This returns TRUE or FALSE
Algorithm will be similar:
if {IsProcessExists(MyApp.exe)}= true then
...
Do something
...
Else
...
Do something else
...
End If
Close Service if programm is closed
Posted: Fri Oct 19, 2012 6:00 am
by datroubler
I managed to first start the service and then start the programm.I know a bit about programming (java) but i dont know where to add the code which you wrote.
Close Service if programm is closed
Posted: Fri Oct 19, 2012 6:20 am
by Oleg
I see that you start service and then you start some application....
What next? What your goal?
What I like to do is that RoboTask checks if an application ( in this case Cisco AnyConnect) is still running (symbol is shown
besides the clock) and if it isn't running anymore the service should be shut down.
It seems you want to stop the service when the program vpnui.exe will be done. This is correct?
In this case create new task with the following algorithm:
if {IsProcessExists(MyApp.exe)}= False then
Stop service vpnagent
End If
You can attach Cyclic trigger to the task.
This task will stop service when vpnui.exe will be finished.
Close Service if programm is closed
Posted: Fri Oct 19, 2012 6:26 am
by datroubler
Yes you got it right.So I can't integrate this function in the already running task?The question sounds stupid but where can I add the code?
Close Service if programm is closed
Posted: Fri Oct 19, 2012 6:41 am
by Oleg
Why do you want to put ALL functions into ONE task???
Sometimes this is VERY unhandy.
Let one task will start service and necessary program
Another task checks status of your program periodically and closes service when program will be finished.
Close Service if programm is closed
Posted: Fri Oct 19, 2012 7:00 am
by datroubler
Ok but still the question:where to put the code?And how to start both tasks with one click?
Close Service if programm is closed
Posted: Fri Oct 19, 2012 7:21 am
by Oleg
There are two tasks. Download here:
1-st task.tsk
2-nd task.tsk
Save tasks to files and use menu Task->Import in order to import into RoboTask. Don't forget to enable both tasks after importing.
2-nd task will run automatically. You don't need start it manually at all
Close Service if programm is closed
Posted: Fri Oct 19, 2012 11:25 am
by datroubler
Wow thanks a lot, works fine. But one question to the second task: Is it running since windows started? I have several programms in which i would like to use this algorithm. Isn't it a prolem for the performance if it checks every 15 seconds if the process is running?Wouldn't it be better so start the second task after the first task?edit:next question:is it possible to (de)activate network adapters?
Close Service if programm is closed
Posted: Fri Oct 19, 2012 3:08 pm
by Oleg
You don't need to start 2-nd task. Just enable it like this:
Start service
Run program
Enable "2-nd task"
at 2-nd task:
if {IsProcessExists(vpnui.exe)} = False then
Disable "2-nd task"
Stop service vpnagent
End If
When you enable task the trigger begin to work and start the task automatically.
BTW: you can set any period: 1 min or 15 min, as you wish.
You may download examples again. I have updated them:
1-st task.tsk
2-nd task.tsk