Click here to Skip to main content
15,885,113 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
i create a window service which call notepad.exe after each 1 hour.
i write code:
C#
protected override void OnStart(string[] args)
{
    timer1 = new Timer();
    timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
    timer1.Interval = 60000;
    timer1.Enabled = true;           
}
void timer1_Elapsed(object sender, ElapsedEventArgs e)
{
    EventLog.WriteEntry("notepad call start");
    Process.Start("notepad.exe");
    EventLog.WriteEntry("notepad is called");
}

after 1 hour eventviewer show "notepad call start" & "notepad is called"
but notepad is not open.how can i solve it.
Posted
Updated 13-Jun-14 4:23am
v2
Comments
Sergey Alexandrovich Kryukov 13-Jun-14 10:41am    
There is not such concept: call an application. The idea is bad. Why doing all that? Please understand: it makes no sense at all.
—SA
DamithSL 13-Jun-14 11:02am    
my 5+ :)
Sergey Alexandrovich Kryukov 13-Jun-14 13:53pm    
Thank you, Damith.
—SA
DamithSL 13-Jun-14 11:01am    
Agreed with SA, this is Bad approach. check Link1[^] and Link2[^] if you really need to do this, read Subverting Vista UAC in Both 32 and 64 bit Architectures[^] article and decide

1 solution

it does start but in the background you need to let the service interact with the desktop.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900