如何让窗口服务打开网页 [英] How to let window service to open a webpage

查看:77
本文介绍了如何让窗口服务打开网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用窗口服务打开网页或运行exe文件,有人可以告诉我如何执行此操作.(窗口7,vs2010)

我的代码是这样的:

I want to use a window service to open a webpage or run an exe file,can someone tell me how to do this.(window 7,vs2010)

my code is like this:

public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();

            System.Timers.Timer t = new System.Timers.Timer();
            t.Interval = 1000;
            t.Elapsed += new System.Timers.ElapsedEventHandler(RunWork);
            t.AutoReset = true;
            t.Enabled = true;
        }

        protected override void OnStart(string[] args)
        {
        }
        public void RunWork(object source, System.Timers.ElapsedEventArgs e)
        {


                File.Open(@"E:\1.txt", FileMode.Open);
                File.Open(@"E:\2.txt", FileMode.OpenOrCreate);

                System.Diagnostics.Process.Start("http://www.baidu.com");
                 //It doesn't run


}
}

推荐答案

尝试一下:

Try this:

using System.Diagnostics; 
... 
Process proc = new Process(); 
proc.StartInfo = new ProcessStartInfo("IExplore.exe", "http://www.baidu.com");

proc.Exited += new EventHandler(Your_Process_Exited_Handler_Here);

proc.Start(); 



希望对您有所帮助:)



hope it helps :)


查看此链接可能对您有所帮助

http://forums.asp.net/t/1413608.aspx/1 [ ^ ]
See this link may help you or not

http://forums.asp.net/t/1413608.aspx/1[^]


这篇关于如何让窗口服务打开网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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