zoukankan      html  css  js  c++  java
  • windows服务安装

    string[] cmdline = { };
    
                        /*E:	estWindowsServiceTestMyWebin*/
                        string path = Server.MapPath("/bin/");
                        string s = Server.MapPath("/bin/WindowsServiceTest.exe");
                        //AssemblyInstaller installer = new AssemblyInstaller();
                        //installer.Path = Server.MapPath("/bin/WindowsServiceTest.exe");
    
                        //installer.UseNewContext = true;
                        //installer.Install(null);
                        //installer.Commit(null);
                        //installer.Dispose();
    
    
                        #region
                        //TransactedInstaller transactedInstaller = new TransactedInstaller();
                        //AssemblyInstaller assemblyInstaller = new AssemblyInstaller(@"E:	estWindowsServiceTestMyWebinWindowsServiceTest.exe", cmdline);
                        //transactedInstaller.Installers.Add(assemblyInstaller);
                        //transactedInstaller.Install(new System.Collections.Hashtable());
                        #endregion
    
                        #region
                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.FileName = "cmd.exe";
                        startInfo.Arguments = "/c C:\Windows\System32\cmd.exe";
                        startInfo.RedirectStandardInput = true;
                        startInfo.RedirectStandardOutput = true;
                        startInfo.RedirectStandardError = true;
                        startInfo.UseShellExecute = false;
                        startInfo.Verb = "RunAs";
                        Process p = new Process();
                        p.StartInfo = startInfo;
    
                        p.Start(); // 启动进程
                        //p.StandardInput.WriteLine(@"del D:123.txt"); // Cmd 命令
    
                        p.StandardInput.WriteLine(@"e:"); // Cmd 命令                 
                        p.StandardInput.WriteLine(@"cd  E:	estWindowsServiceTestWindowsServiceTestinDebug"); // Cmd 命令
                        p.StandardInput.WriteLine(@"installutil WindowsServiceTest.exe"); // Cmd 命令
    
                        p.StandardInput.WriteLine("exit"); // 退出
    
                        #endregion
  • 相关阅读:
    自己动手实现一个WEB服务器
    Java SPI机制和使用示例
    Redis笔记(七):Redis应用场景
    Linux笔记:linux常用命令
    Linux笔记:vi常用命令
    PostgreSQL执行超时的问题
    Redis笔记(五):Redis发布订阅
    Redis笔记(四):Redis事务支持
    Redis笔记(三):Redis常用命令
    Redis笔记(二):Redis数据类型
  • 原文地址:https://www.cnblogs.com/tgdjw/p/4955187.html
Copyright © 2011-2022 走看看