I've written some test code based on a Help example.
Assuming I get a ServiceController using the ServiceController.GetServices
call, is there any way to use that to get the executable path of the Windows
Service?
Hi,
If you're trying to get executable path of a Windows Service, here is
the one that i've generated for you:
' ///////////////////////////////////
'First, add reference to System.Management.dll
' Assuming you want to get "Messenger" service's path
'Import Management namespace
Imports System.Management
Dim searcher As New ManagementObjectSearcher _
("root\CIMV2", "SELECT * FROM Win32_Service Where Name=""Messenger""")
For Each queryObj As ManagementObject In searcher.Get()
' For example, get path in a messagebox
MsgBox(queryObj.GetPropertyValue("PathName").ToString)
Next
' ///////////////////////
Just change, "Messenger" service name in query command to another
which one you desire to get executable path.
Hope this helps,
Onur Güzel