Creating a windows service

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
akincer
Posts: 43
Last visit: Thu Mar 14, 2024 7:53 am

Creating a windows service

Post by akincer »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2020 build 5.7.179
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit

*** Please add details and screenshots as needed below. ***

Is there any detailed documentation and/or examples of creating a windows service via a Windows Service Project? My testing is not going well.

I added a single file to the project (Main) and added a line to invoke it in Startup.pss and it doesn't do anything fancy. On install, the service fails to start. Attempting to manually start it gives the following error:

Code: Select all

Windows could not start the TestServiceProject service on Local Computer.

Error 193: 0xc1
In the event log, there's this:

Code: Select all

The TestServiceProject service failed to start due to the following error: 
TestServiceProject is not a valid Win32 application.
Attempting to upgrade fails and says I don't have sufficient permissions which is not true. Attempting to uninstall is hit or miss as to whether it will work or not. Sometimes it does, sometimes it fails and sets the service as disabled. Rebooting removes it properly.

The OS I'm testing this on is Widows Server 2016.
User avatar
akincer
Posts: 43
Last visit: Thu Mar 14, 2024 7:53 am

Re: Creating a windows service

Post by akincer »

After additional testing it appears you must first compile the service project then add the exe as the file for the MSI. Is this expected?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Creating a windows service

Post by Alexander Riedel »

Probably best to start out with these:
https://www.sapien.com/blog/2017/07/12/ ... owershell/
https://www.sapien.com/blog/2018/02/27/ ... ript-2018/
https://www.sapien.com/blog/2018/03/05/ ... owershell/
https://www.sapien.com/blog/2018/06/25/ ... malscript/
https://www.sapien.com/blog/2018/07/09/ ... er-engine/

They are based on PrimalScript but the differences are minimal. Some UI elements have been updated or moved obviously but it still works that way.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.