views:

54

answers:

2

Hi

i am trying to make an event logger for my cmd line application. However I get this error when it tries to create the log for the first time.

The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

So I found this is a because of windows 7 and some new security. So right now I have to give the .exe admin rights.

Is there a way around this so it would not need admin rights? I don't know if people would feel too good if they have to contently run my application with admin rights.

I am planning to put this later on a windows 2008 machine so I am guessing it will suffer from the same problem.

+3  A: 

You could create the event source at the point of installation so they only need to make that choice once. Once the source is created in the registry you can add events to it without the need for admin rights.

As well as the CreateEventSource function there is also the EventLogInstaller class:

http://msdn.microsoft.com/en-us/library/system.diagnostics.eventloginstaller.aspx

WiX also offers this functionality in it's Utility extension:

http://stackoverflow.com/questions/58538/how-do-you-create-an-event-log-source-using-wix

fletcher
How could I make this event source at installation?
chobo2
I updated the post with some more information
fletcher
So what do I just put a arguement and say maybe like install? Then it just installs it and thats it?
chobo2
Ok I tried that msdn tutorial and when my application ran I just ran my cmd line application and called that Installer thing but when I look in my event log view I don't see the log.
chobo2
A: 

NETWORK SERVICE OR Impersonated User must have Read/Write access to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security

Jeroen
But then I would have access to every eventLog?
chobo2
Your question was about creating an eventlog for your application. On Windows 2008 this is what you need. (I suppose on win7 too, in that case i'd have the app's install run as admin giving the app the correct rights so from then on you won't need to run it as admin constantly.)
Jeroen