mohantyd
asked on
How to reset windows service when settings file changes
I have a windows service which watch a folder for arrival of new files.
windows service take this foldrrs path from a settings file .
When some one modify setting file how to reset windows service to watch diferent folder mentioned in settings file?
i have called this watcher in OnStart method.
Code will be much appreciated
windows service take this foldrrs path from a settings file .
When some one modify setting file how to reset windows service to watch diferent folder mentioned in settings file?
i have called this watcher in OnStart method.
Code will be much appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Normally, some process would need to communicate with the service to tell it to re-read its settings file and take appropriate action. This could be done through any sort of IPC mechanism, TCP, named pipe, etc.
Or... here's an idea: It could monitor for changes in its settings file. When it has been modified, it could automatically take action.
The simplest solution might be to simply stop the service and restart it. For instance, this pair of command lines would do it:
net stop MyService
net start MyService
Or... here's an idea: It could monitor for changes in its settings file. When it has been modified, it could automatically take action.
The simplest solution might be to simply stop the service and restart it. For instance, this pair of command lines would do it:
net stop MyService
net start MyService
http://www.codeproject.com/KB/system/CServiceWrapper.aspx
(OpenSCManager, OpenService, ControlService, ...)