I wrote a windows service on Visual Studio. It's a bot actually based on Selenium. It needs to log in to my account on a website every 8 hours. The problem is it waits for the time to be passed (for 8 hours) and then starts getting executed. I want it to get started once I start the windows service and then keep running every 8 hours. I used windows service template on Visual Studio.
protected override void OnStart(string[] args)
{
WriteToFile("Service is started at " + DateTime.Now);
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = 28800000;
timer.Enabled = true;
}