switch (rs)
            {
                case 1:
                  
                    var path = @"e:\WindowsServiceTest.exe" + " s";
                    Process.Start("sc", "create myserver binpath= \"" + path + "\" displayName= StrongunionService start= auto");

Process p = new Process();
                    p.StartInfo.FileName = "cmd.exe";
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardInput = true;
                    p.StartInfo.RedirectStandardOutput = false;
                    p.StartInfo.RedirectStandardError = true;
                    p.StartInfo.CreateNoWindow = true;
                    p.Start();
                    string Cmdstring = "sc start myserver"; //CMD命令
                    p.StandardInput.WriteLine(Cmdstring);
                    Console.WriteLine("安装成功");
                    Console.Read();
                    break;
                case 2:
                    Process p2 = new Process();
                    p2.StartInfo.FileName = "cmd.exe";
                    p2.StartInfo.UseShellExecute = false;
                    p2.StartInfo.RedirectStandardInput = true;
                    p2.StartInfo.RedirectStandardOutput = true;
                    p2.StartInfo.RedirectStandardError = true;
                    p2.StartInfo.CreateNoWindow = true;
                    p2.Start();
                    string Cmdstring2 = "sc stop myserver"; //CMD命令
                    p2.StandardInput.WriteLine(Cmdstring2);
                    Process.Start("sc", "delete myserver");
                    Console.WriteLine("卸载成功");
                    Console.Read();
                    break;
                case 3:
                    
                    Console.WriteLine("卸载成功000");
                    Console.Read();
                    break;

}

最新文章

  1. Spring事务管理----声明式:利用TransactionProxyFactoryBean生成事务代理
  2. Android下如何计算两经纬点之间距离
  3. [JavaScript]顺序的异步执行
  4. struts2结果(Result)
  5. 接口API测试和返回值JSON解析的插件
  6. seafile
  7. bzoj 3270 博物馆(高斯消元)
  8. J - 搞笑版费马大定理
  9. HDU - 1394 Minimum Inversion Number (线段树求逆序数)
  10. C++编程剖析 问题 方案 和设计准则
  11. c++常见变量的极值
  12. 每天学点SpringCloud(十二):Zipkin全链路监控
  13. NopCommerce用.net core重写ef
  14. JAVA-数据库之MySQL与JDBC驱动下载与安装
  15. Netty入门(3) - ChannelHandler
  16. MVC无刷新上传图片并显示
  17. sublime text3 汉化
  18. Python之路(第十五篇)sys模块、json模块、pickle模块、shelve模块
  19. Leetcode[1]Two Sum C++
  20. Hadoop集群datanode死掉或者secondarynamenode进程消失处理办法

热门文章

  1. [SDOI2010]古代猪文 (欧拉,卢卡斯,中国剩余)
  2. rem,em
  3. MGR架构 ~ MGR+proxysql(2)
  4. 修正iOS从照相机和相册中获取的图片方向
  5. geeksforgeeks-Array-Rotation and deletion
  6. android 使用web查看SQLite数据
  7. oracle建包,函数demo
  8. 基于theano的降噪自动编码器(Denoising Autoencoders--DA)
  9. Potential Pythonic Pitfalls
  10. L0/L1/L2范数(转载)