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
                { }
            }
  • 相关阅读:
    go excel导入Demo
    redis限流Lua脚本
    线上机器CPU与内存升高排查
    错点
    自动化运维工具——ansible详解(一)
    k8s之命令记录
    k8s之监控集群资源利用率
    根据经纬度搜索附近的人
    微信小程序直接打开h5页面
    【python3】字符串格式化
  • 原文地址:https://www.cnblogs.com/94cool/p/1710289.html
Copyright © 2011-2022 走看看