zoukankan      html  css  js  c++  java
  • .net创建并安装windows服务案例

    1. 创建windows服务【引用博文】:

    1. 将这个服务程序切换到设计视图
    2. 右击设计视图选择“添加安装程序”
    3. 切换到刚被添加的ProjectInstaller的设计视图
    4. 设置serviceInstaller1组件的属性:
    1) ServiceName = My Sample Service
    2) StartType = Automatic
    5. 设置serviceProcessInstaller1组件的属性
    1) Account = LocalSystem
    6. 生成解决方案

    注意:尝试同时启用多服务,个人测试并没有成功!

    ServiceBase[] ServicesToRun;
    ServicesToRun = new ServiceBase[]
    {
    new NFSMainService()
    };
    ServiceBase.Run(ServicesToRun);

    ServiceBase[] 数组中放多个服务时,只能运行第一个,看了许多博文但未能解决,不过我们可以将多个服务以类的形式放到一个服务中。

    2.安装服务有两种方法:

    1.通过InstallUtil程序去安装:通过打开Visual Studio .NET命令,格式:路径 InstallUtil.exe MyWindowsService.exe;

    卸载的话:格式:路径 InstallUtil.exe MyWindowsService.exe /u

    但如果到客户方部署的话,生产环境未必有Visual Studio .NET命令,这种情况我们可以打包服务,也可以使用cmd命令:

    sc create 服务名字 binPath=  E:TestWindowsApplication1WindowsService1inDebug WindowsService1.exe,回车;

    binPath=后面需要加空格。

    卸载:

    SC delete 服务名字

  • 相关阅读:
    1月19号 UIImageView
    1月18号 UILabel 加上导入.tff格式的字体
    1月18号 UIButton
    2016年 1月15号 cocoapods的导入
    1月12号 UIView
    12月30号 iOS程序准备
    12月29号 计算器(包含混合运算)
    2016.01.13 代理设计模式
    2016.01.04 视图控制器UIViewController
    2015.12.31 iOS程序准备(developer.apple.com)
  • 原文地址:https://www.cnblogs.com/guozefeng/p/4169607.html
Copyright © 2011-2022 走看看