Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

I have service running on clients machine , Whenever we made some changes in service exe the we provide the and replace it manually.
Is it is possible to that service check at share location if there are latest version available the stop it self and replace the exe to latest and start it self.

What I have tried:

i have create a separate thread form service which will stop  service and copy file but not able to start.
Posted
Updated 23-Jun-17 6:40am

You have to have a second executable that does that. An .EXE cannot replace itself as the file is locked when the code is running.

Your "updater" .EXE would need to run every once in a while, check the installed version of the service against the one available on the server. If a different version is available, get the new service executable, stop the service, replace the .EXE and restart the service.

Your "updater" could either be a normal console app that's launched from Windows Scheduled Tasks or could be written as its own service.
 
Share this answer
 
Dirty trick: Windows does allow a running executable to be renamed, see this CodeProject article about it: Simple Auto-Update: Let your application update itself using 2 lines of code[^]
Don't know if this will work for a service however ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900