zoukankan      html  css  js  c++  java
  • 设置c#windows服务描述及允许服务与桌面交互

    private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
            {
                try
                {
                    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 = "Net Start Service1"; //CMD命令
                    string Cmdstring = "sc config " + serviceInstaller1.ServiceName + " type= interact type= own";
                    p.StandardInput.WriteLine(Cmdstring);
                    Cmdstring = "sc start " + serviceInstaller1.ServiceName;
                    p.StandardInput.WriteLine(Cmdstring);
                    p.StandardInput.WriteLine("exit");
                }
                catch
                { }
            }
  • 相关阅读:
    JavaScript基础
    WordPress站点绑定多个域名
    linux下如何把php升级到5.6
    ansible shell 之运行后台程序
    Redhat7 开机启动服务
    模拟jenkins通过shell给ansible传入变量
    ansible-playbook权限提升多种方式
    ansible删除目录下所有内容
    ansible 文件和目录操作
    linux 用户和组管理
  • 原文地址:https://www.cnblogs.com/94cool/p/1710289.html
Copyright © 2011-2022 走看看