473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

windows service with its own event log

Unless I make the account under which my Windows Service runs a member of
local Administrators, I get startup failures if I include the following code
in the OnStart() event :

if(!EventLog.SourceExists("MyLog"))
{
EventLog.CreateEventSource("My Log", "Application");
}
EventLog appLog = new EventLog();
appLog.Source = eventSource;
appLog.WriteEntry("Test Log Entry",EventLogEntryType.Information);
Seems extreme to make a Service's credentials a member of local
Administrators ... any ideas ?


Nov 17 '05 #1
2 1570
Hi John,

In order to create a new Event Source, you need to be a member of the
Administrators group. One workaround is to have a separate program that
creates the source for you, then you can run just this program from an
admin account, and your service can still run under "non-admin" credentials.

Regards,

Bennie Haelen

John Grandy wrote:
Unless I make the account under which my Windows Service runs a member of
local Administrators, I get startup failures if I include the following code
in the OnStart() event :

if(!EventLog.SourceExists("MyLog"))
{
EventLog.CreateEventSource("My Log", "Application");
}
EventLog appLog = new EventLog();
appLog.Source = eventSource;
appLog.WriteEntry("Test Log Entry",EventLogEntryType.Information);
Seems extreme to make a Service's credentials a member of local
Administrators ... any ideas ?

Nov 17 '05 #2
Hi John,

In order to create a new Event Source, you need to be a member of the
Administrators group. One workaround is to have a separate program that
creates the source for you, then you can run just this program from an
admin account, and your service can still run under "non-admin" credentials.

Regards,

Bennie Haelen

John Grandy wrote:
Unless I make the account under which my Windows Service runs a member of
local Administrators, I get startup failures if I include the following code
in the OnStart() event :

if(!EventLog.SourceExists("MyLog"))
{
EventLog.CreateEventSource("My Log", "Application");
}
EventLog appLog = new EventLog();
appLog.Source = eventSource;
appLog.WriteEntry("Test Log Entry",EventLogEntryType.Information);
Seems extreme to make a Service's credentials a member of local
Administrators ... any ideas ?

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bill Sonia | last post by:
I've written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that for OnShutDown, once my...
2
by: Chris Dunaway | last post by:
I am attempting to use the AppDomain.UnhandledException event in a Windows Forms app and also in a Windows Service. But the event doesn't seem to be called. In a Windows Forms app, the event IS...
27
by: pisquem | last post by:
I am building an windows service that is to be deployed on a windows server 2003 and I want to have activity written to the event log, I want its own log called ('CustomLog') Below is what I...
0
by: Jason | last post by:
Ok, for the life of me, I just don't understand what's going on. I want to use remoting to send messages from a windows service to a windows form app, but I just can't get it to work. So, here's...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.