none
How to create always running .NET 2008 Windows Forms application? RRS feed

  • Question

  • Hi,

    In .NET 2008 I'm trying to create an 'Windows Forms' application that runs always.
    I tried with Windows Sevice but launching a desktop applicaiton from the service is not advisable it seems due to security constraints (in Win7 this has even more restrictions). 

    So what is the best way to make a .NET desktop application to run always???

    For example, suppose if I create Windows Forms application with GUI say some application, "TimeSheetReminder.exe". This executable should be always runing in the user machines and should come up whenever it is needed.

    Another thing is, if a user goes to the TaskManger and kill this application also, it should automatically re-launch itself.

    Bascially I'm looking for, how to create a .NET desktop application that runs always in the background and launches itself whenever needed / re-launches itself if somebody forcefully kills it.

    I think my requirement is a very common thing.

    Kindly help me out to achieve this?

    Thanks & regards,
    Krish TS

    Tuesday, September 27, 2011 6:44 AM

All replies

  • I don't believe this is a very common requirement actually (if you exclude malware developers of course).

    Anyway, there is nothing special about .NET in this request. Find a way for normal C++ unmanaged application and apply it to your application.

    Using a service sounds like the right way to me. Security of course will be the concern.

    -Karel

    Tuesday, September 27, 2011 4:05 PM
    Moderator
  • Another solution for ur problem will be.. If you want to make sure ur app is running always in all scenarios

    --> Have a System tray application (for ur reminders-- so that u can interact with desktop)

    --> Have a Winodows service which polls the health of the application periodically. If it is stopped, then restart the app. Allow admins / whatever groups have permissions on it.  Atleast Admins can  kill the app.

     

    Hope this may work.


    --Krishna
    Tuesday, September 27, 2011 4:26 PM
  • Krishna,

    It is easy to tell restart the app. from the windows service, but how?
    If a service can able to restart the app, then why I should go for system tray and other ? I will directly make the service iteslf to take care of this, right?!!!

    Point 1: If you deploy a windows service in Win7 and make the service to trigger an UI exe, the OS will altert whether the service should open the application or not to user.

    Point 2: If from the exe (that is triggered by the service) if you open an IE, the browser is running is least privilige mode, meaning it will not open any site (it will go safe mode alert).

    Do you have any better suggestions for these queries?

    Wednesday, September 28, 2011 6:15 AM
  • In order to restart an application, you might register windows scheduler task which will execute script or executable under specific user account.

    There are managed libraries available for creating windows scheduler tasks, just search "windows scheduler .net wrapper"


    Please remember to mark the replies as answers if they help
    Wednesday, September 28, 2011 2:26 PM
  • Having it running "all the time" makes no sense. You can't run a GUI program when nobody is logged on, and if it's a reminder for a human being then it doesn't need to be running when there are no human beings logged on.  I think what you really need is just a program that runs whenever a user logs on, and you can make that happen by having an entry in the HKLM\Software\Microsoft\Windows\CurrentVersion\Run" key.


    Phil Wilson
    Wednesday, September 28, 2011 6:12 PM