windows服务安装

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

 

转载于:https://www.cnblogs.com/tgdjw/p/4955187.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Windows服务安装卸载工具是一种用于管理和操作Windows操作系统中的服务的软件工具。它能够帮助用户方便地安装、卸载、启动、停止和管理各种Windows服务。 首先,Windows服务安装卸载工具提供了一种简单的方法来安装和卸载服务。用户只需双击安装文件,按照提示进行操作,即可快速地安装或卸载服务。这样,即使用户没有相关的技术知识,也能轻松地完成这些操作。 其次,该工具还允许用户对服务进行启动、停止和重启等操作。用户只需选中相应的服务,然后点击相应的按钮,即可实现服务的启动、停止或重启。这使得用户可以方便地控制和管理系统中的各个服务。 此外,Windows服务安装卸载工具还提供了服务状态的监控功能。工具可以实显示服务的运行状态,包括是否正在运行、已停止或发生错误等。这使得用户可以随了解系统中各个服务的运行状况,及进行处理和调整。 最后,Windows服务安装卸载工具还支持对服务的属性进行配置和调整。用户可以通过该工具,修改服务的启动类型、依赖关系、服务路径等属性,以满足系统的需求和优化服务的运行。 综上所述,Windows服务安装卸载工具是一款功能强大、操作简单的软件工具。它的存在可以帮助用户更轻松地管理和操作系统中的各个服务,提高操作效率和系统稳定性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值