Get the PID of a Windows service

后端 未结 3 1395
星月不相逢
星月不相逢 2021-02-19 03:37

Could anyone help me to know how to get the PID of a Windows service?
I need to get the PID in order to run the following command:

Process.Start(new Process         


        
3条回答
  •  悲哀的现实
    2021-02-19 04:11

    See this answer on a similar question: Finding out Windows service's running process name

    Using a WMI query you can -

    Find all services related to a single exe (a single exe can host multiple services):

    select Name from Win32_Service where ProcessId = 588

    Or, to answer this question, you can get the PID of the process that a service is running in:

    select ProcessId from Win32_Service where Name = 'wuauserv'

提交回复
热议问题