Answered by:
How to control Windows Service using Windows Form?????

Question
-
I have a Windows Service (read a file from Path). Now I program Windows Forms to set path and start above Windows Service...
Can you help me??????
Thursday, April 19, 2012 4:02 PM
Answers
-
Henry Nguy?n wrote:
I have a Windows Service (read a file from Path). Now I program Windows Forms to set path and start above Windows Service...
Can you help me??????The ServiceController class (require admin/elevation) let you start/stop/pause/resume a windows service:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspxIf you want more specific/verbose dialogue with your service, you can host a very simple wcf service using, for example, named pipes or another binding.
This way, your winform app can add a service reference to the service and use it remotely.
Please note that if you want to authenticate the client before talking, you may not want to use named pipe binding that does not support security and is only local (client can't live in another pc on the network).
If you either want security or control the service from the network, you can use the other transport/bindings.This is the correct approach as the service and the client lives in two different processes and also different sessions (session 0 for the service and >0 for interactive desktops).
Raffaele Rialdi http://www.iamraf.net
Weblog: http://blogs.ugidotnet.org/raffaele
Microsoft MVP profile https://mvp.support.microsoft.com/profile/raffaele
UGIdotNET - http://www.ugidotnet.org/
Raffaele Rialdi [MVP] My articles and videos: http://www.iamraf.net Italian blog: http://blogs.ugidotnet.org/raffaele- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Thursday, April 19, 2012 4:40 PM -
- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Thursday, April 19, 2012 5:01 PM -
http://www.csharp-examples.net/restart-windows-service/
http://msdn.microsoft.com/en-us/library/aa984464(VS.71).aspx
http://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C
http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx
http://stackoverflow.com/questions/6667799/c-sharp-start-windows-service-programmatically
Kindly have a look at the above links.
Regards,
Narendran Ponpandiyan
- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Friday, April 20, 2012 4:11 AM
All replies
-
Henry Nguy?n wrote:
I have a Windows Service (read a file from Path). Now I program Windows Forms to set path and start above Windows Service...
Can you help me??????The ServiceController class (require admin/elevation) let you start/stop/pause/resume a windows service:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspxIf you want more specific/verbose dialogue with your service, you can host a very simple wcf service using, for example, named pipes or another binding.
This way, your winform app can add a service reference to the service and use it remotely.
Please note that if you want to authenticate the client before talking, you may not want to use named pipe binding that does not support security and is only local (client can't live in another pc on the network).
If you either want security or control the service from the network, you can use the other transport/bindings.This is the correct approach as the service and the client lives in two different processes and also different sessions (session 0 for the service and >0 for interactive desktops).
Raffaele Rialdi http://www.iamraf.net
Weblog: http://blogs.ugidotnet.org/raffaele
Microsoft MVP profile https://mvp.support.microsoft.com/profile/raffaele
UGIdotNET - http://www.ugidotnet.org/
Raffaele Rialdi [MVP] My articles and videos: http://www.iamraf.net Italian blog: http://blogs.ugidotnet.org/raffaele- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Thursday, April 19, 2012 4:40 PM -
- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Thursday, April 19, 2012 5:01 PM -
http://www.csharp-examples.net/restart-windows-service/
http://msdn.microsoft.com/en-us/library/aa984464(VS.71).aspx
http://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C
http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx
http://stackoverflow.com/questions/6667799/c-sharp-start-windows-service-programmatically
Kindly have a look at the above links.
Regards,
Narendran Ponpandiyan
- Marked as answer by Bob Shen Monday, May 7, 2012 2:43 AM
Friday, April 20, 2012 4:11 AM