-1

Is is possible to start/stop windows service via some other windows service or same windows service? I have windows service running on multiple PCs, As I want to update that service whenever any version change, So I want to handle windows service via code with some other or same windows service?

Krutika Patel
  • 420
  • 5
  • 16

1 Answers1

1

Typically upgrading a service requires replacing its exe and supporting DLLs but no additional registry changes unless something about the service registration is to be altered (startup type for example).

There's no reason why your service cannot launch a small updater program that will stop, replace and restart the service but generally you won't succeed in getting any running program to replace itself because the exe tends to end up locked/in use while it is running. The updater program doesn't need to be registered as a service

Be mindful that you might have to launch the updater using credentials that have permission to stop/restart a service and alter the program files subfolders; services should generally run using the lowest (least permission) possible and running an updater app using the same credentials might not give high enough privileges to replace the exe

See How can a program delete its own executable for more ideas on self replacing programs

Caius Jard
  • 72,509
  • 5
  • 49
  • 80