Page 1 of 1

Building a Windows Service

Posted: Sat May 18, 2019 12:29 am
by TimStone
We haven't discussed this in a couple of years. I need to take a program I run on the server 24/7/365 from an application that is run as a service. We tried this several years ago ( and discussed it here ) but it never actually worked properly.

I'd like to know if anyone has mastered this technology. I'm using Visual Studio 2019 with Harbor and FWH latest version. The service is an auto updater and does not need anything in the way of a screen display and does not need any i/o interactions.

In doing this, and linking harbour libraries, which ones do we actually need to include for the smallest build possible.

Thanks for the ideas and experiences you may share.

Tim

Re: Building a Windows Service

Posted: Sat May 18, 2019 10:26 am
by toninhofwi
Hi Tim, I use this model and it works fine:

https://github.com/harbour/core/blob/ma ... ervice.prg


Regards.

Re: Building a Windows Service

Posted: Sun May 19, 2019 6:52 pm
by Busmatic_wpb
Hello, I want to know how it is applied, an example, I thank you very much
Regards..

Re: Building a Windows Service

Posted: Wed May 22, 2019 12:30 am
by TimStone
Do you have a build routine ? What are you using for compiling, and linking ?

Re: Building a Windows Service

Posted: Wed May 22, 2019 5:29 pm
by toninhofwi
to compile service.prg I use this:

---cut---
set PATH=c:\bcc\bin;%PATH%

\harbour-install\bin\hbmk2 service -lhbwin -lace32 -lrddads -iC:\harbour-install\contrib\hbwin
---cut---


Regards.

Re: Building a Windows Service

Posted: Wed May 22, 2019 6:35 pm
by TimStone
OK ... I can build the application and get an .exe. ( I'm using Microsoft Visual Studio 2019 ). As an .exe it runs as expected but is not visible. That is fine.

When I try to run it from the Developer's Command Prompt using abc.exe I it gives me an access denied error. Any thoughts ?

Re: Building a Windows Service

Posted: Thu May 23, 2019 6:29 pm
by TimStone
Still looking for input ... but I did get it to install and "run" ( or at least it says it is running ).

Following the example suggested above:

I place the .exe that is to be run as a service in a folder where the data is located. I need to use those data files. Normally, since the program is located in the directory, I can use commands to find the "path" by identifying the directory and folder. The system path is then used as the "default".

If I hardcode in the path, all is working. However, that path may change depending on where the IT "professional" decides to install the software.

I'm also curious about a question that came up before. I'd love to have the service simply call another .exe file ( but the discussion previously indicated someone would still have to be logged in ). That would allow me to update the service file easily. I would simply have to replace the 2nd exe ( non-service ). Anyone done this ?