Building a Windows Service

Post Reply
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Building a Windows Service

Post 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
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Re: Building a Windows Service

Post by toninhofwi »

Hi Tim, I use this model and it works fine:

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


Regards.
User avatar
Busmatic_wpb
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: Building a Windows Service

Post by Busmatic_wpb »

Hello, I want to know how it is applied, an example, I thank you very much
Regards..
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
_@Situcr.com
Desarrollos BA4/B4j androide
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Building a Windows Service

Post by TimStone »

Do you have a build routine ? What are you using for compiling, and linking ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Re: Building a Windows Service

Post 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.
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Building a Windows Service

Post 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 ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Building a Windows Service

Post 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 ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Post Reply