C#实现Windows 服务的制作安装和删除[转]
2009-11-25 11:18
357 查看
关于C#实现windows服务的制作与安装还有删除
运行Visual Studio.NET,建立一个C#的Windows服务项目。
主程序代码:
以下是引用片段:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
namespace CareEye
添加安装组件:
在设计页面上点右键,出现菜单后,选择添加安装程序。这时会出现一个新的页面,页面上有个控件 serviceProcessInstaller1和serviceInstaller1
在 serviceProcessInstaller1中把属性Account改为LocalSystem
在把serviceInstaller1中把属性Parent 改为serviceProcessInstaller1 ServiceName属性是管生成服务后的名子
添加完成之后,生成一下(假设名为W2.exe)。到相应的文件夹找到生成的exe文件,找到时会发现有两个.exe用名子比较短的那个。把这个文件拷到一个好记的文件夹中如F盘根目录。
这时就是要把个服务安装一下。进入cmd中的画面,进入Framework2.0的文件如:
cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
后在打
InstallUtil f:\w2.exe 这个就安装了服务 卸载服务是 InstallUtil f:\w2.exe -u
现在就剩启动服务了,
到windows服务里启动你安装的服务就可以了。
运行Visual Studio.NET,建立一个C#的Windows服务项目。
主程序代码:
以下是引用片段:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
namespace CareEye
添加安装组件:
在设计页面上点右键,出现菜单后,选择添加安装程序。这时会出现一个新的页面,页面上有个控件 serviceProcessInstaller1和serviceInstaller1
在 serviceProcessInstaller1中把属性Account改为LocalSystem
在把serviceInstaller1中把属性Parent 改为serviceProcessInstaller1 ServiceName属性是管生成服务后的名子
添加完成之后,生成一下(假设名为W2.exe)。到相应的文件夹找到生成的exe文件,找到时会发现有两个.exe用名子比较短的那个。把这个文件拷到一个好记的文件夹中如F盘根目录。
这时就是要把个服务安装一下。进入cmd中的画面,进入Framework2.0的文件如:
cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
后在打
InstallUtil f:\w2.exe 这个就安装了服务 卸载服务是 InstallUtil f:\w2.exe -u
现在就剩启动服务了,
到windows服务里启动你安装的服务就可以了。
相关文章推荐
- C#实现Windows 服务的制作安装和删除
- C#实现Windows 服务的制作安装和删除
- C#实现Windows 服务的制作安装和删除
- C#Windows 服务制作安装删除. 用户注销后,程序继续运行
- C#实现Windows 服务的制作安装和删除
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service
- C#实现windows服务安装,服务名可配置时出问题(无法创建 ProjectInstaller 安装程序类型的实例)
- C#制作 Windows 服务安装程序
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service(downmoon原创)
- C#实现Windows服务的制作安装和删除
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service
- .NET C# 实现 Windows 服务的安装及反安装
- C#制作 Windows 服务安装程序
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service
- c# Windows服务的安装及删除
- C# windows服务安装程序的制作
- C#制作Windows service服务系列一:制作一个可安装、可启动、可停止、可卸载的Windows service
- C#实现对Windows 服务安装