Bartosz Pierzchlewicz
Bartosz Pierzchlewicz

Reputation: 526

How to know who started/stopped windows service in .NET

Is the way to check in ServiceBase's void OnStart, void OnStop methods, who initialized action? I need username to write it into log.

Upvotes: 1

Views: 1161

Answers (1)

Rhapsody
Rhapsody

Reputation: 6077

You could take the currently logged on user. (my.user.name)

Or for example use the Autolog property. This will automatically write an entry to the event log when a service is started/stopped.

Mybase.AutoLog = true

I hope this answers your question, otherwise please let me know.

Upvotes: 1

Related Questions