Page 1 of 1

Windows Service Validation Check to Inhibit Service Start

Posted: Sun May 24, 2020 7:34 am
by sereini
Hello,

I've been playing a bit with this and overall get how it works and have created/installed a basic service without issue:

https://www.sapien.com/blog/2017/07/12/ ... owershell/

I'm sure I'm just missing something but I'm trying to prevent the service from starting should something like a file/directory/reg key not be present. As as an example, one thing I've tried is this:

if (-Not (Test-Path "C:\ValidationFolder")) {Exit}

But I've also tried triggering the function Stop-MyService, creating my own functions, inserting code like the above within, etc.

I'm running PrimalScript 2019 v7.4.125.0

Thx!

Re: Windows Service Validation Check to Inhibit Service Start

Posted: Sun May 24, 2020 8:03 am
by jvierra
Just make you checks in "Service-MyService" and don't set the bServiceRunning flag so the service will nver enter the run loop.
Why is that an issue?