zoukankan      html  css  js  c++  java
  • C# 安装布署 及Windows服务自动启动

    设置serviceProcessInstaller1控件的Account属性为“LocalSystem”
    设置serviceInstaller1控件的StartType属性为"Automatic"
    在服务器上添加安装程序,在private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)事件中,添加以下代码:
    Process p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.CreateNoWindow = true;
    p.Start();
    string Cmdstring = "sc start myservice"; //CMD命令
    p.StandardInput.WriteLine(Cmdstring);
    p.StandardInput.WriteLine("exit");
    即可在安装服务后立刻启动windows服务
     
     
    注: 引用using System.Diagnostics;//调用Process
     
    C#安装布署
    建立一个新的安装项目ServerSetup(为刚才那个服务建立一个安装项目)
    右键-添加-项目输出-主输出-选择Service1-确定
    右键-视图-自定义操作-自定义操作上右键-添加自定义操作-打开应用程序文件夹-选择刚才那个主输出-确定
    重新生成这个安装项目-右键-安装
     
     
    查看服务,,则自已的服务("myservice")已自动启动 ......
  • 相关阅读:
    关于一道PHP面试题的解法
    ThinkPHP学习(二)
    ThinkPHP学习(一)
    Apache 创建虚拟主机目录和设置默认访问页面
    awk全集
    初识云计算&openstack
    Python collections
    Python 函数/高阶函数
    Python dic/set/迭代
    python matplotlib 图标绘制
  • 原文地址:https://www.cnblogs.com/luoyaoquan/p/2079929.html
Copyright © 2011-2022 走看看