473,408 Members | 2,734 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,408 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 1571
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.