Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I've coded a program to monitor the printing activities, so how would I make a service to prevent closing the program or let the user close it but the program still work in the background as it's service still running.

Also, I prefer to use a built-in service in an installer that does the same.

Thank you.

What I have tried:

what I'm thinking of is to make a service that monitor the process and prevent the program from closing by not to let the user terminate the process.
is there any better suggestion?
Posted
Updated 11-Oct-20 23:08pm
v2
Comments
Sandeep Mewara 11-Oct-20 7:05am    
If it's an activity of monitoring, why is it a program? Make that itself as a windows service that runs on the system and capture the print activities and log it.

User is not even interacting with it and thus no need to worry about preventing closing of an app which is not good even if you achieve.
Tomas Ladeti 11-Oct-20 13:56pm    
it's actually a software with a UI, such as some controls to adjust what to monitor, but what I want to keep monitoring even if the program is closed.
Dave Kreskowiak 12-Oct-20 11:59am    
Yeah, you can't prevent the app from closing. You can see that the process goes away and relaunch it, but even that's a pain in the ass to do as your service has to launch the process as the logged in user (there could be MULTIPLE people logged in at the same time!) AND you have to make sure the process gets launched on the correct desktop, an even bigger pain in the ass.
Tomas Ladeti 15-Oct-20 3:47am    
So there is no a built in service to so that, I mean an installer has this feature?
Dave Kreskowiak 15-Oct-20 9:52am    
No, there is no built-in way to do that, and NO, an installer does NOT have this feature.

The "feature" you're talking about is the Restart Manager. It can NOT restart applications as the user if the installer (or your service) is running as LocalSystem. It can only do that if the installer is running as the user that's logged in.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900