是否可以通过其他 windows 服务或相同的 windows 服务使用 start/stop windows 服务?

Is is possible to start/stop windows service via some other windows service or same windows service?

是否可以通过其他 windows 服务或相同的 windows 服务使用 start/stop windows 服务?我在多台 PC 上有 windows 服务 运行,因为我想在任何版本更改时更新该服务,所以我想通过代码处理 windows 服务和其他一些或相同的 windows 服务?

通常升级服务需要替换其 exe 和支持的 DLL,但不需要额外的注册表更改,除非要更改有关服务注册的某些内容(例如启动类型)。

你的服务没有理由不能启动一个小的更新程序来停止、替换和重新启动服务,但通常你不会成功地让任何 运行ning 程序来替换它自己,因为 exe 倾向于在 运行ning 期间结束 locked/in 使用。更新程序不需要注册为服务

请注意,您可能必须使用有权访问 stop/restart 服务并更改 program files 子文件夹的凭据来启动更新程序;服务通常应该 运行 使用尽可能低的(最少权限)并且 运行 使用相同凭据的更新应用程序可能不会提供足够高的权限来替换 exe

有关自我替换程序的更多想法,请参阅 How can a program delete its own executable