JFLarvoire / SysToolsLib

A library of Windows and Linux system management tools
Apache License 2.0
314 stars 93 forks source link

Update PSService.ps1 #12

Closed rblindberg closed 6 years ago

rblindberg commented 6 years ago

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.

JFLarvoire commented 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.