Well, I created task scheduler manually, this scheduler gets triggered when Windows App logs system event message. I.e. In Trigger tab of scheduler, Select "
On an event" from "
Begin the task" drop down, add source name, Add EventID. While logging a message through App, Source and EventID should be same as mentioned in the task scheduler.
In Action section, select "
Start a program" option, in program/script textbox add "%windir%/system32/sc.exe", in "
Add argument" textbox add
start "Windows Service Name".
Once task created, right click task >> export, this will create an xml.
Added this XML in INNO SETUP as a part of deployment package, this will register event to the machine whenever application is installed.
Also, added event log on windows application OnStart event.
So, whenever application is started, OnStart event is fired, Log will be registered to System Event Log, with specific ID and Source. Once the log is entered, associated scheduler will be triggered, which will start Windows service
Below is c# code for loggin message to event viewer through OnStart event
protected override void OnStartup(StartupEventArgs e)
{
const string Source = "TestWindowsApp", Log = "Application", Event = "TestWindowsApp Application Started";
const int EventID = 16317;
if (!EventLog.SourceExists(Source))
EventLog.CreateEventSource(Source, Log);
EventLog.WriteEntry(Source, String.Format("{0}: {1}", Event, System.DateTime.Now), EventLogEntryType.Information, EventID);
}