您的位置:首页 > 其它

一个完整的Windows 服务从创建到安装卸载

2013-05-29 09:36 330 查看
第一、创建一个Windows服务



第二、在自动生成的Program类中写你要写的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace WindowsTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
}
}
}


第三、安装程序


第四、改变一下属性





第五、找到bin文件夹下的文件



第六、输入一下命令

1、输入cmd(命令行),输入cd C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319,2.0为cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

2、InstallUtil "E:\接口\接口测试\WindowsTest\WindowsTest\bin\Debug\WindowsTest.exe"

第七、卸载

InstallUtil/u "E:\接口\接口测试\WindowsTest\WindowsTest\bin\Debug\WindowsTest.exe"

第八、在服务里找到你发布的项目



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: