I've never made any attempt to use NSSM, since you can create services with Visual Studio easily, including using the free Visual Studio Community version. One you get into underlying interface stuff, you have to resort to dev-like efforts. PoSH does a huge number of things, but it does not do everything for you. Many times, you are going to have to dig and write the needed items for your use case yourself.
Shouldn't the NSSM interface provide this access methods to you, since it is the one doing this?
The WM_CLOSE, WM_QUIT methods are part of a Windows Class,
... generally accessed doing stuff like this:
$src = @'
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
Add-Type -TypeDefinition $src
Of course, as I said, I have never spent anytime messing with NSSM, but if it were me, I'd contact them first and ask how they are doing this and how one can get at the underlying stuff.
After looking at it again NSSM has a shutdown tab, I unchecked all the boxes, then in the PowerShell script read the service status through $Service_Status = (get-service $Service_Name).status.tostring().toupper() and look for -ne RUNNING
So now if I right click on the service and choose stop it shuts down gracefully 🙂
You must be logged in to reply to this topic.