none
Run Windows Application From Windows Service? RRS feed

  • Question

  • Hi,

    I have made a windows service that has a timer checks for a certain time to remind me. Now the time is reached so i want the service to display an alert!!

    I have made a windows app that shows the alert but when i run it from the service it runs but not GUI displayed!!!

    I can see it runs from the Task Manager but i cant show the form.

    So is there any way to dispay i GUI alert from a windows service?

     

    Thanks a lot

    Wednesday, October 18, 2006 1:31 PM

Answers

All replies

  • Thanks  i know how .NET remoting works, but this way i will make the windows service is listening to a certain port and the alert app would be the client, so how the server run the client app??

    Client app should be closed all the time until the time for alert so it runs the alert

    Wednesday, October 18, 2006 2:55 PM
  • Well, you will probably have to make the client app sit in the background and check in with the service at certain intervals. once the service tells the client app (when it checks in with the service) that there is an alert to display then the app can display the form. there is no way of getting out of it. the client will have to either run in the background or you will have to use the task scheduler service for client app checkins. if you try to run your app from a windows service it will run in the user context of the service. for example. if your windows service runs in the SYSTEM account then if you try to run the GUI from the service. the GUI will display but, only on the SYSTEM account. since you cannot login to the system account it will not work. even if you tried your applcication running under your user account it still will not work as the service would start the GUI under a different session then the one you are logged into. you are left with either letting your client run in the background and checking in with the service or, running it through the task scheduler and check in that way.

    Quilnux

    Wednesday, October 18, 2006 3:09 PM
  • Hmm i see, thanxxx.

    I this is right the way that Antiviruses use, the main app is always running.

    I hoped the i could make the load less.

    Wednesday, October 18, 2006 3:25 PM
  • window service has a property "Interact with Desktop". Set it to true, Re install the service and see what happens.

    I hope this will work!

    Best Regards,

    Wednesday, October 18, 2006 4:15 PM
  •  RizwanSharp wrote:

    window service has a property "Interact with Desktop". Set it to true, Re install the service and see what happens.

    I hope this will work!

    Best Regards,

     

    Not sure if this would work but if so make sure you have the user account the service uses to be the user account you want to see the app window from. this would also make the application only work for 1 user, the one that the service runs as.

    Wednesday, October 18, 2006 4:19 PM
  • Thanks RizwanSharp,

    You are a smart, i get now out of this complexity if .net remoting or any other solutions, it worked fine for all users existing.

    Wednesday, October 18, 2006 4:39 PM
  • Hello Mr  TheMaj0r

    I have doubts on the same topic,But I am new to .NET and  I don't have any idea abt .NET remoting ,Can u plz post code How to run  windows application from windows service,

    or Plz give me step by step process How to do it ,I hope u will understand my Request,I will be waiting for u r replay

    Regards

    GovardhanReddy

    Wednesday, January 31, 2007 5:36 AM
  • Hello Mr  TheMaj0r

    I have a problem on the same topic. But I am beginner on .NET and  I don't have any about .NET remoting. Can u please post code? How to run  windows application from windows service?

    or Plz give me step by step process. How to do it ,I hope u will understand my Request and help me, Can you send me your code? my email : aagii_jp@yahoo.com
    I will be waiting for u r reply...

    Regards aagii

    Thursday, February 8, 2007 10:29 AM
  • Sorry guys for being late !!

    if you want windows service to call or run windows app so u need to use

    System.Diagnostics.Process.Start(appName , args);

    and this is like you run the app with command prompt, but the problem is that the win service doesnt support GUI so you have to change the proberty of the win serv interact with desktop to true, this will allow win serv to run GUI apps.

    Regards

    Saturday, February 17, 2007 4:00 PM
  • Hi major,

            Below is the code which we use to print files(can be .pdf,txt,doc ).

     

    SetDefaultPrinter("\\01hw111683\\ZoneThree");

    ServProcess.StartInfo.CreateNoWindow = true;

    ServProcess.StartInfo.FileName = "c:\\Projects\\test.txt";

    ServProcess.StartInfo.Verb= "Print";

    ServProcess.StartInfo.UseShellExecute = true;

    ServProcess.Start();

    SetDefaultPrinter is an api to set default printer. rest i guess u can understand. The problem is i cant change the property to run on local system account(client requirement) so i cant make it interactive with desktop. I have looked on net but no alternates are there. Its like microsoft dont allow access to printer from windows service at all. I am so busted. Its kind of urgent. Please help.

    Friday, May 18, 2007 8:33 AM
  •  

    Hi Mr. PJ. van de Sande,

            Below is the code which we use to print files(can be .pdf,txt,doc ).

     

    SetDefaultPrinter("\\01hw111683\\ZoneThree");

    ServProcess.StartInfo.CreateNoWindow = true;

    ServProcess.StartInfo.FileName = "c:\\Projects\\test.txt";

    ServProcess.StartInfo.Verb= "Print";

    ServProcess.StartInfo.UseShellExecute = true;

    ServProcess.Start();

    SetDefaultPrinter is an api to set default printer. rest i guess u can understand. The problem is i cant change the property to run on local system account(client requirement) so i cant make it interactive with desktop. I have looked on net but no alternates are there. Its like microsoft dont allow access to printer from windows service at all. I am so busted. Its kind of urgent. Please help.


    Friday, May 18, 2007 8:39 AM
  •  

    guys m sorry i'm too late to post this question

    I'm having same kinda issue, that i need to call the log off through the windows service.

    what i understood is that if you set the property "interact with desktop" to true, the it would work.

    but problem is that i canot find the property in my windows service, Vs 2005 .NET 2.0, VB.NET

     

    But currently it calls the function to logoff the operating system but nothing happens,

     

    Same functionality works absolutly fine when I run my program as windows application rather than windows service.

     

    any help is appreciated.

     

    regard - raheel

    Saturday, May 3, 2008 9:19 AM
  • Write an event log and check what error is coming from the Windows service

    First of all the onStart() should return to the OS after finishing the work. It is a precondition of Windows Services.

    So I dont think u can call the logoff in onStart()...

    Better to check wt error comes in the event log..
    Friday, February 12, 2010 5:43 AM