码迷,mamicode.com
首页 > Windows程序 > 详细

windows服务安装

时间:2015-11-11 09:59:36      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

string[] cmdline = { };

                    /*E:\test\WindowsServiceTest\MyWeb\bin*/
                    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:\test\WindowsServiceTest\MyWeb\bin\WindowsServiceTest.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:\test\WindowsServiceTest\WindowsServiceTest\bin\Debug"); // Cmd 命令
                    p.StandardInput.WriteLine(@"installutil WindowsServiceTest.exe"); // Cmd 命令

                    p.StandardInput.WriteLine("exit"); // 退出

                    #endregion

 

windows服务安装

标签:

原文地址:http://www.cnblogs.com/tgdjw/p/4955187.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!