2015-08-03 87 views
1

我有一個Windows服務。 現在我要反安裝並重新安裝它,但如果我嘗試用這個命令安裝它,我有這樣的錯誤:如何unistall窗口服務

InstallUtil.exe GestoreService.exe 

的錯誤是

它和異常發生在安裝過程。 System.ArgumentException:原始GestoreService已經存在於本地計算機中

我該如何解決這個錯誤?

這是主代碼:

public GestoreService() 
{ 
    InitializeComponent(); 
    try 
    { 
    if (!System.Diagnostics.EventLog.SourceExists("LoggerGestore")) 
    { 
     System.Diagnostics.EventLog.CreateEventSource(
     "LoggerGestore", "LoggerGestore"); 
    } 
    } 
    catch (Exception e) 
    { 
    log.Error(e); 
    } 

    log.Info("preparazione file di config in corso..."); 
} 

回答

3

首先卸載已經安裝的服務:

InstallUtil.exe /u GestoreService.exe 

然後再重新安裝:

InstallUtil.exe GestoreService.exe 
1

安裝服務無法再次安裝,直到它被卸載。您需要使用/卸載開關,以提供卸載服務,您可以瞭解更多關於installutil上Installutil.exe (Installer Tool)

作爲一個附加的註釋,如果你想更新一些服務的.exe文件那麼你並不需要的庫卸載並重新安裝。所有你需要做的就是停止該服務,替換舊文件(Assemblies/.exe)和開始它再次。

InstallUtil.exe GestoreService.exe /uninstall 

或者你可以用短的/uninstall作爲/u

InstallUtil.exe /u GestoreService.exe