41

When I try to install a Windows service:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil

I get, what looks to be, some success messages and some failure messages. Part way down:

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service has been marked for deletion

At the end:

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

The service is given an entry in the Services applet, but it is marked as "Disabled". When I attempt to change it to another state, I get a "marked for deletion" error message.

There are no messages in the Event Log. There is nothing useful in the log file created by installutil.exe (I believe it's written to the current working directory).

I have no direction to go with this. What do I do?

Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105
  • possible duplicate of [How to force uninstallation of windows service](http://stackoverflow.com/questions/225275/how-to-force-uninstallation-of-windows-service) – participant Jun 26 '15 at 10:34

6 Answers6

96

It turns out that the install might, or probably will, fail if that service is highlighted in the Services applet. It's safest to just close the Services applet, install the service, and then re-open the Services applet. It's really stupid.

Also, make sure to run the console as admin.

Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105
  • That damned applet is really annoying the way it always gets in the way. – ProfK Mar 10 '15 at 15:48
  • In my case the applet did not have the service highlighted, and was not even focused on the Services tab - it was in Event Viewer. Welcome to the wonderful world of Microsoft's misleading and confusing error messages, I guess? – ajeh Jul 04 '16 at 20:53
  • I don't believe your last remark @ajesh, but I'm also having no joy. Even with the applet completely closed off. How am I supposed to control this damn service. I'm so frustrated right now!! – Sizons Jul 06 '16 at 08:48
  • Haha, thank you so much for figuring this out for me. "Really stupid" is right! – Joe Irby Mar 29 '17 at 19:39
  • Really Bad... Can't expect this rubbish from Windows. – School Boy Sep 16 '17 at 06:49
  • 1
    @SchoolBoy Actually, I find it comfortingly consistent. – Dustin Oprea Sep 17 '17 at 06:58
11

I experienced the same and the issue for me was that a service with the same name was already installed. So in order to install the new service I had to uninstall the older services. I am learning how to create and setup windows services and thus the naming conflicting. Tried uninstalling the service first through:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil -u servicename.exe

Once this statement executes successfully, install your service and it should succeed without any rollbacks.

Sarah
  • 1,895
  • 2
  • 21
  • 39
  • If I remember correctly, I had already uninstalled the service, but it had remained highlighted in the Services applet. – Dustin Oprea Feb 10 '14 at 23:53
  • @DustinOprea if the service was uninstalled successfully, it should not appear in the list of services you see through the "services.msc" window – Sarah Feb 11 '14 at 05:30
  • There's a "refresh" action available in that window, for a reason. However, it wasn't so simple. As I already mentioned, it's been long enough that I can no longer provide any additional insights to it. – Dustin Oprea Feb 11 '14 at 15:51
3

Right Click on Command Prompt and choose RUN AS ADMINISTRATOR
Then copy and paste in: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe C:\TestService\bin\Debug\TestService.exe

Result in TestService.InstallLog is:

Installing service TestService...
Service TestService has been successfully installed.
flen
  • 1,905
  • 1
  • 21
  • 44
1

Some times this happens due to permission issues. Run the "Developer Command Prompt for VS 2012" as Administrator. Then it will work.

  • It didn't make a difference. Something breaking simply because something else is highlighted is an application bug, not a permissions issue. – Dustin Oprea Jan 28 '16 at 14:37
0

Adding few more check's and points to solve this above issue.

  1. Build service in release mode and take release folder files and kept in different path
  2. Copy that path and go to visual studio command prompt window and run this bellow sample command to install the service.
  3. Please close services.msc window if its opened , then run C:Program Files (x86)\Microsoft Visual Studio 11.0>InstallUtil.exe C:\RunLocationServices\TestService.exe
  4. Go services.msc and select that service and click on start ,if it changed to "started" then your service running fine.

Still if issue exists then Another Checkpoint & SOLUTION When a service starts, the service communicates to the Service Control Manager how long the service must have to start (the time-out period for the service). If the Service Control Manager does not receive a "service started" notice from the service within this time-out period, the Service Control Manager terminates the process that hosts the service. This time-out period is typically less than 30 seconds. If you do not adjust this time-out period, the Service Control Manager ends the process. To adjust this time-out period, follow these steps: 1.Go to Start > Run > and type regedit 2.Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control With the control folder selected, right click in the pane on the right and select new DWORD Value 3.Name the new DWORD: ServicesPipeTimeout 4.Right-click ServicesPipeTimeout, and then click Modify Click Decimal, type '180000', and then click OK 5.Restart the computer

Still if issue exists then problem in your service code ,infinate loop may occur due to your methods/classes of service calling. Do code review of each line.

DJ21
  • 1
  • 2
0

This problem is due to security, you'd better open developer command prompt for VS 2012:

RUN AS ADMINISTRATOR

and install your service. It will surely fix your problem.

I tried and the issue was resolved.

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90