如何在Windows服务中调用任何应用程序(E.G.Notepad.Exe)? [英] How Can I Call Any Application(E.G. Notepad.Exe) In Windows Service?

查看:93
本文介绍了如何在Windows服务中调用任何应用程序(E.G.Notepad.Exe)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个窗口服务,每1小时后调用notepad.exe。

i编写代码:

i create a window service which call notepad.exe after each 1 hour.
i write code:

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");
}


$ 1 $ b在1小时后,事件观看者显示记事本呼叫开始& 记事本被称为

但记事本不是open.how我可以解决它。


after 1 hour eventviewer show "notepad call start" & "notepad is called"
but notepad is not open.how can i solve it.

推荐答案

它确实启动但在后台你需要让服务与桌面交互。
it does start but in the background you need to let the service interact with the desktop.


这篇关于如何在Windows服务中调用任何应用程序(E.G.Notepad.Exe)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆