locked
Prevent a user from killing an application. RRS feed

  • Question

  • I'm coding a simple monitor application to monitor print jobs. Every time a user creates a print i need to make him type in a bit of information. Now, applications like these are usually the first ones people try to shut down because they are very annoying to most people. However, I need to, some how, prevent people from doing this.

     

    I was thinking about writing a service that would present a GUI but that's not really the best of ideas, and probably impossible to do in Vista because of all the extra security.

     

    I could also create an application, and have it run at startup, only showing it's gui when the user prints something. But that will enable the user to shut the application down through the Task manager. This solution would however work if i could somehow check if the application was running, and restart it if it wasn't.

    I seem to remember trying to get rid of a virus dll at some point, but no matter how many times I killed it through the task manager it always reappeared shortly after. How did they do that?

     

    Perhaps it's not even possible to achieve this but what are my options here. Any help would be greatly appreciated.

     

    Thanks,

     

    Morten Andersen

    Monday, December 10, 2007 4:51 PM

Answers

  • Man, testing this sucks, because now I have to reboot to get rid of the program!

     

    Okay, in program.cs, before Application.Run add the following code:

     

    Code Block

    Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

     

     

     

    Then, add the event handler:

     

    Code Block

    static void Application_ApplicationExit(object sender, EventArgs e)

    {

    Application.Restart();

    }

     

     

    Monday, December 10, 2007 7:16 PM

All replies

  • The windows service idea would probably be best but if your users are admins on their own computers it still can be killed.

     

    I am assuming you are printing in a server enviroment to shared printers.  I do not know if this exists but maybe there is some functionality in the server print queue system that will get you were you need to be.  If it does exist at least the users will not be able to kill it.

     

    Monday, December 10, 2007 7:05 PM
  • Man, testing this sucks, because now I have to reboot to get rid of the program!

     

    Okay, in program.cs, before Application.Run add the following code:

     

    Code Block

    Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

     

     

     

    Then, add the event handler:

     

    Code Block

    static void Application_ApplicationExit(object sender, EventArgs e)

    {

    Application.Restart();

    }

     

     

    Monday, December 10, 2007 7:16 PM
  •  Morten Andersen wrote:

    I seem to remember trying to get rid of a virus dll at some point, but no matter how many times I killed it through the task manager it always reappeared shortly after. How did they do that?

     

    Perhaps it's not even possible to achieve this but what are my options here. Any help would be greatly appreciated.

     

    Thanks,

     

    Morten Andersen

     

    Sounds like aspiring malware developerSmile

     

    You perhaps tried to kill rundll.exe. This creature behaved this way. The problem was that nobody knew it it was a virus or an MS systems dll. If the latter is the case, the system symply restarted it.

     

    You are not a pioneer. Some others have been coming around with the same question, I suspect true experts got tired of answering it. If I am not mistaken the overall answer was IMPOSSIBLE.

     

    I really hope this is the case. Just talk to your users, Offer them candy as a reward. Learn interpersonal skills. Forget about writing viruses. Take a sleeping pill tonight. It helps.

    Monday, December 10, 2007 10:26 PM
  • The problem with this application is that most user will probably do what they can to avoid having to register every print they make and most managers will only find it usefull if they can be sure that everything gets registered. I will give your suggestion a try tomorrow but i seem to remember reading somewhere that using the ApplicationExit event to cancel application shut down would introduce problems when trying to shut down windows. But maybe Restarting will behave differently. I will give it at shot.

    @Alex:

    I can see where you get the idea that I might be developing malware but my intensions are honest enough although some users might think of print registration apps as a form of malware. 

    The current vb6/C++ implementation of the app actually uses the service approach but vistas extended security features makes it more or less impossible to do this. And besides I have always learned that having a service controlling the gui and not the other way around was a serious no no. 
    Monday, December 10, 2007 10:45 PM
  • I'm running XP SP2 on this workstation. I had no problems restarting... so shutting down should be fine. Keep in mind you're not cancelling the application's exit, you're restarting the application. I think Windows keeps new programs from starting during it's shut down process.

    Monday, December 10, 2007 11:07 PM