Installutil won't uninstall: "The specified service does not exist as an installed service"
Asked Answered
B

3

6

I have been trying to install a Windows service using installutil: installutil /u GSIS.FileMoverService.exe.

The output I get is :

Uninstalling assembly 'C:\FMS\GSIS.FileMoverService.exe'. Affected parameters are:

logtoconsole = logfile = C:\FMS\GSIS.FileMoverService.InstallLog

assemblypath = C:\FMS\GSIS.FileMoverService.exe Removing EventLog source File Mover Service.

Warning: The source File Mover Service is not registered on the local machine. Service File Mover Service is being removed from the system...

An exception occurred during the uninstallation of the System.ServiceProcess.ServiceInstaller installer. System.ComponentModel.Win32Exception: The specified service does not exist as an installed service An exception occurred while uninstalling.

This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete.

The service has been stopped when I try to uninstall. It's definitely registered as a services. I've rebooted and it's still visible in the Services applet (services.msc). It also starts and stops successfully from the Services applet, so it doesn't look like it's been unsuccessfully (or only partially) installed.

I am calling installutil from the VS2010 Command Prompt (having clicked Run As Administrator).

Any ideas?

Banks answered 28/11, 2012 at 15:6 Comment(0)
B
14

In the end I used sc delete GSIS.FileMoverService to remove the service. This worked.

Banks answered 28/11, 2012 at 15:51 Comment(1)
What does it do?Justify
A
3

So I expect this has to do with your class that is extending System.Configuration.Install.Installer. In the constructor of your class, you are expected to add a System.ServiceProcess.ServiceProcessInstaller and System.ServiceProcess.ServiceInstaller to Installers like:

public MyServiceInstaller(string displayName = null, string description = null, ServiceAccount account = ServiceAccount.LocalSystem, string username = "", string password = "", ServiceStartMode startType = ServiceStartMode.Automatic, bool delayedAutoStart = false, string[] servicesDependedOn = null)
{
    Installers.Add(new ServiceProcessInstaller
        {
            Account = ServiceAccount.LocalSystem,
            Username = username,
            Password = password
        });
Installers.Add(new ServiceInstaller
    {
        ServiceName = GetType().Name,
        StartType = startType,
        DisplayName = displayName ?? serviceName,
        Description = description ?? string.Empty,
        ServicesDependedOn = servicesDependedOn,
        DelayedAutoStart = delayedAutoStart
    });

}

The ServiceName in ServiceInstaller needs to match the ServiceName assigned to the ServiceInstaller when the service was installed. If it does not, then you will get this exception because it cannot find the service installed before it tries to uninstall.

Anele answered 6/12, 2013 at 19:1 Comment(0)
B
0

I had a similar problem with Windows Services. I checked this thread and the information was very helpful, I just added an additional command, made sure the CMD was running with administrator permissions, and running the following commands from the CMD was able to uninstall the service: sc getkeyname "service name" sc delete "service name"

Balmuth answered 28/6, 2023 at 22:32 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Glendon

© 2022 - 2024 — McMap. All rights reserved.