Building a Windows Service

Building a Windows Service

Postby TimStone » Sat May 18, 2019 12:29 am

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Building a Windows Service

Postby toninhofwi » Sat May 18, 2019 10:26 am

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

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


Regards.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Re: Building a Windows Service

Postby Busmatic_wpb » Sun May 19, 2019 6:52 pm

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
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: Building a Windows Service

Postby TimStone » Wed May 22, 2019 12:30 am

Do you have a build routine ? What are you using for compiling, and linking ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Building a Windows Service

Postby toninhofwi » Wed May 22, 2019 5:29 pm

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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Re: Building a Windows Service

Postby TimStone » Wed May 22, 2019 6:35 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Building a Windows Service

Postby TimStone » Thu May 23, 2019 6:29 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Silvio.Falconi and 120 guests