Page 1 of 1

My TaskScheduler as a service ....

Posted: Mon Oct 30, 2017 11:41 pm
by ChrisGillard
Hi,

I have a Xailer TaskScheduler program that is very successful and I am trying converting it to run as a service.

All is going well and it appears to run as a service 95% OK, except for my Timer function when it wants to actually execute the task .... calling my RunNow() method.

My problem is how to run the required .exe from within my program running as a service.

The 'non service' code that works fine is this

METHOD RunNow() Class ScheduledTask

Execute( ::cFile, FilePath( ::cFile ) )

RETURN( self )

This would work fine with ::cFile = "c:\windows\system32\notepad.exe" ..... notepad pops up on the PC main window in the usual way.

Problem is it appears to not do anything visible when executed from a service.

So question is :

1. Can I execute a program from a Xailer service program to appear on the PC main window ... I really hope so!
2. What is the function to do this, possibly ShellExecute or ????

Any help would be appreciated.

Thanks

Chris

Re: My TaskScheduler as a service ....

Posted: Tue Oct 31, 2017 5:39 pm
by ignacio
Hi,

1) I believe is not possible, sorry.

Regards,

Re: My TaskScheduler as a service ....

Posted: Fri Nov 10, 2017 6:41 pm
by ChrisGillard
Oh dear, thats not what I wanted to hear.

Is this something to do with how Xailer has implemented the service code ?

There are some other 3rd party Task Schedulers that do run as services and can launch exes plus of course Windows own Task Scheduler.

I can see that Microsoft would want it to be difficult to do because of worries of malware, virus etc.

Oh dear, I was very pleased with my code, but its not much use now.

If you get a 'eureka' moment and can see how to do it, please let me know.

Chris

Re: My TaskScheduler as a service ....

Posted: Mon Nov 13, 2017 6:17 pm
by ignacio
ChrisGillard wrote:Oh dear, thats not what I wanted to hear.

Is this something to do with how Xailer has implemented the service code ?

There are some other 3rd party Task Schedulers that do run as services and can launch exes plus of course Windows own Task Scheduler.

I can see that Microsoft would want it to be difficult to do because of worries of malware, virus etc.

Oh dear, I was very pleased with my code, but its not much use now.

If you get a 'eureka' moment and can see how to do it, please let me know.

Chris


2017-11-13 18_16_28-Introduction to Windows Service Applications _ Microsoft Docs.png
2017-11-13 18_16_28-Introduction to Windows Service Applications _ Microsoft Docs.png (14.82 KiB) Viewed 1431 times

Re: My TaskScheduler as a service ....

Posted: Tue Nov 14, 2017 1:39 pm
by ChrisGillard
Hi Ignacio,

Thanks for continuing with this.

I was fairly aware about that no interaction was possible.

The applications I want to run are things like night time 'batch jobs', written in Harbour that do not interact with the screen but just do various 'housekeeping' jobs and when finished they just exit.

Maybe my example of notepad.exe was a bad one.

I have not actually tried to run one of our Harbour 'batch jobs'.

I will have a go and see.

Regards

Chris