Simplest way to restart service on a remote computer

后端 未结 11 1941
我寻月下人不归
我寻月下人不归 2020-12-23 13:07

What\'s the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn\'t matter as long as it doesn\'t require human interaction.

11条回答
  •  旧巷少年郎
    2020-12-23 13:49

    1. open service control manager database using openscmanager
    2. get dependent service using EnumDependService()
    3. Stop all dependent services using ChangeConfig() sending STOP signal to this function if they are started
    4. stop actual service
    5. Get all Services dependencies of a service
    6. Start all services dependencies using StartService() if they are stopped
    7. Start actual service

    Thus your service is restarted taking care all dependencies.

提交回复
热议问题