window服務建立

來源:互聯網
上載者:User

標籤:blog   http   使用   io   2014   art   代碼   ar   

第一步:建立服務


 

第二步:在Service1.cs視圖中 右鍵 選擇”添加安裝程式”

這裡要注意幾個細節 設定上面的屬性 這兩個分別有屬性,具體網上查使用方式

3 執行個體代碼編寫 主要下面幾個方法

    protected override void OnStart(string[] args)
        {
          
            timer.Interval = 1000 * 60*24;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }
        protected void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
           
        }
        protected override void OnStop()
        {
            timer.Stop();
        }

服務寫好了後,需要產生

產生成功後,需要開啟該項目產生exe的路徑

最後一步也就是最重要的一步安裝了

開啟vs命令提示字元,注意要以管理員的身份啊,不然會安裝失敗。

InstallUtil.exe D:\Documents\Visual_Studio_2010\Projects\WindowsService\ZZ_WindowsService\bin\Debug\ZZ_WindowsService.exe (注意事項:路徑不允許有空格,具體路徑就是你的window服務生產路徑)

卸載 window服務路徑

輸入 InstallUtil.exe /u 空格  D:\Documents\Visual_Studio_2010\Projects\WindowsService\ZZ_WindowsService\bin\Debug\ZZ_WindowsService.exe


 


  
  
  
  
  
  
  
  
  
 
 
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.