I have a bunch of win services written in .NET that use same exact executable with different configs. All services write to the same log file. However since I use the same .exe
I use this function in VB
Private Function GetServiceName() As String
Try
Dim processId = Process.GetCurrentProcess().Id
Dim query = "SELECT * FROM Win32_Service where ProcessId = " & processId.ToString
Dim searcher As New Management.ManagementObjectSearcher(query)
Dim share As Management.ManagementObject
For Each share In searcher.Get()
Return share("Name").ToString()
Next share
Catch ex As Exception
Dim a = 0
End Try
Return "DefaultServiceName"
End Function