Reputation: 2169
I have a windows service. Now I want to unistall it and re-install it but I have this error if I try to install it with this command:
InstallUtil.exe GestoreService.exe
The error is
It and exception occurred During Installation . System.ArgumentException : Origin GestoreService already existing in the local computer
How can I fixed this error?
This is the main code:
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...");
}
Upvotes: 1
Views: 142
Reputation: 148180
Installed service could not be installed again until it is uninstalled. You need to use /uninstall switch in order to uninstall service, you can learn more about installutil on Installutil.exe (Installer Tool)
As a additional note if you want to update some of libraries of service .exe file then you do not need to uninstall and install it again. All you have to do is to stop the service, replace the the old files (Assemblies/.exe) and start it again.
InstallUtil.exe GestoreService.exe /uninstall
Or you can use short for /uninstall
as /u
InstallUtil.exe /u GestoreService.exe
Upvotes: 1
Reputation: 219087
First uninstall the service that's already installed:
InstallUtil.exe /u GestoreService.exe
Then re-install:
InstallUtil.exe GestoreService.exe
Upvotes: 3