Closed rblindberg closed 6 years ago
Sorry for the long delay reviewing this. I suspect the critical thing that was missing in my code was the "-ExecutionPolicy Bypass" option. I've merged your changes, although they did not work as submitted: There was a missing } at the end of the onStop code, which caused a fatal error when using the -Setup option! I've then pushed a change with that } added. With that everything works fine.
Updated the C# OnStop() procedure adding execution policy bypass flag and the following sections try{ }catch{ }finally{ } This resolved the issue where stopping the service would leave the PowerShell process -Service still running. This unclosed process was an orphaned process that remained until the pid was manually killed or the computer was rebooted.