Writing to the event log without admin

255 views Asked by At

I am admin on my local machine. However the app I am creating (an outlook VSTO addin) will be deployed by a deployment admin to users who won't have admin.

The app installs correctly.

My issue is that I have code which checks if an EventLog.SourceExists("my VSTO addin"). If not it will EventLog.CreateEventSource("my VSTO addin").

My questions:

  1. Do I really need to create an event source? Will it still log without the source existing?
  2. How should I create the event source (if #1 is required)?

2a Perhaps I need to create a small app which creates the event source and this needs to be installed by an admin?

2b Perhaps I can put it in the code somewhere which will invoke when its being installed? (I'm using install shield)

2c Perhaps it can be done by an admin as part of group policy?

2d I can create a registry key as per https://learn.microsoft.com/en-us/windows/desktop/EventLog/event-sources

1

There are 1 answers

0
Sniipe On BEST ANSWER

To answer my questions: I do need create the source. To solve this I created another console app which just creates the event log sources I require. In installshield I added this new exe as a custom action. The install is done with Admin mode so the sources are created. This fixes the application because non admins were using the app and it was trying to create the event log sources if they didn't exist. I removed this check.