日期:2014-05-19  浏览次数:20808 次

不需要命令InstallUtil 安装windows服务
public   partial   class   QYService   :   ServiceBase
        {
                public   QYService()
                {
                        this.ServiceName   =   "QYService ";
                }

                protected   override   void   OnStart(string[]   args)
                {
                        Process.Start( "test.bat ");
                }

                protected   override   void   OnStop()
                {
                        //   TODO:   在此处添加代码以执行停止服务所需的关闭操作。
                }
        }

------------------------------

  [RunInstallerAttribute(true)]
        public   partial   class   ProjectInstaller   :   Installer
        {
                private   System.ServiceProcess.ServiceProcessInstaller   serviceProcessInstaller;
                private   System.ServiceProcess.ServiceInstaller   serviceInstaller;

                public   ProjectInstaller()
                {
                        this.serviceProcessInstaller   =   new   System.ServiceProcess.ServiceProcessInstaller();
                        this.serviceInstaller   =   new   System.ServiceProcess.ServiceInstaller();
                        //  
                        //   serviceProcessInstaller
                        //  
                        this.serviceProcessInstaller.Account   =   System.ServiceProcess.ServiceAccount.LocalSystem;
                        this.serviceProcessInstaller.Password   =   null;
                        this.serviceProcessInstaller.Username   =   null;
                        //  
                        //   serviceInstaller
                        //  
                        this.ser