I am creating a windowservice that starts a process where I pass multiple cmd arguments in the StartInfo.Arguments
. That works fine as expected.
The problem is that when i stop the windowsservice, I need to tell the running program to shut down gracefully before the windows service stops. Because if I just kill the process the program does not save the collected data. The program that I run is the Process Monitor and it accepts the following command "/terminate"
.
How can I pass the /terminate
argument before my windows service stops?
start /wait
, then stops the service withsc stop
command?/Terminate
argument and with that it stoppes all process monitor instances gracefully.