Can I stop/Start an external Windows Service (written in VB.Net) From a VB.Net App?

kumarshah

Member
Joined
May 10, 2006
Messages
16
Programming Experience
Beginner
I have a Windows Service written that prints barcodes at regular intervals.

I have another application using which the user can modify an XML file with configuration settings in it.

Now, I wanted to know is it possible that when the user modifies the XML file using the external application, I can either stop/start the service or restart it so on initialization it will read in the XML config file again?

Another question is, can I pass in parameters from a form into a Windows Service?
 
Thanks.

From what I gather, Windows Service are not able to accept parameters from a Windows Form Application?

Thanks again
 
Wrong. As mentioned you can use the ExecuteCommand with the ServiceController to pass integer values.
 
You can have an internal method in the service that reads a particular file and fetches data from there. This method can be invoked when you tell the service to ExecuteCommand #1 for instance..
 
You know from the controlling application where that config file is. Store that knowledge in the file c:\knowledge.txt and tell the service to read it. Registry is also a place where you may store the knowledge.
 
As you say, store it in c:\knowledge.txt, the problem is that it might be c:\ might be g:\ might be h:\ when it goes to the client site.
 
No, you totally misses the point, wherever that config file is someone must know it - the controlling application knows it, and it can store the path to that config file somewhere that the service will always find it. If you store the path in the file c:\knowledge.txt you can tell the service to execute its method #1, the service will then read the path from the file c:\knowledge.txt (or a registry setting).
 
Back
Top