I have a simple service with the following code:
on Program.Main method I have the code which is generated by vs itself(2010):
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
}
And in Service1.cs I have:
protected override void OnStart(string[] args)
{
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(@"C:\doorbell-1.wav");
myPlayer.Play();
}
protected override void OnStop()
{
}
I have omit writing the usual automatically generated c# codes to reduce the complexity.
Logically a sound should be played when I start the service but nothing happens when I start the service. Please note that:
1-I install the service using installUtill.exe. 2-The service runs under the localSystem account privilege. 3-Duration of the mentioned .wav file is 3Seconds.
How can I play that sound? Thanks in advance.