I have created windows service for tomcat server and it is running well but now I want to change service name without deleting it.

so is there any cmd\GUI steps to change service name?


@bfhd's answer will work if you just want to change the Display Name (which is what's shown in the list in Services.msc, but is not the "real" service name (which is the name of the registry key containing the service information, and used in APIs like OpenService). The Remarks section of this MSDN article talks about service names vs. display names a bit more.

Unfortunately, there's no official way to change a service's name. However, it is probably possible, if you absolutely must rename the service instead of just re-installing it under the new name for some reason. Do the following:

  1. Stop the service. You will probably confuse the service control manager if you do this on a running service. (You may confuse it anyhow, this is very hacky.)
  2. Open regedit.exe (Registry Editor).
  3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and find the subkey with your service's name.
  4. Right-click the key you found in step #3, and select Rename. Enter the new name for the service.
  5. Restart the computer. Services.exe, the process that hosts the service control manager, won't see the change unless you do; attempts to start the renamed process (or otherwise interact with it at all, actually) will fail.

I make no promise of this working. It's probably worth trying, though, if for some reason just reinstalling the service under a new name is so unacceptable.

If you must do this programmatically, there may exist a function RegRenameKey that can do the fourth step above for you. I stress may exist because, so far as I can tell, this function is completely unofficial; it's not in MSDN and there's precious little info about it. The only thing I found, other than the Windows headers (which have the prototype, and indicate that it's only on Vista - NT6.0 - and newer), is a Sysinternals forum post, which indicates that it calls an NT syscall (also undocumented). The function prototype, from WinReg.h, is

    _In_ HKEY hKey,
    _In_opt_ LPCWSTR lpSubKeyName,
    _In_ LPCWSTR lpNewKeyName
| improve this answer | |
  • WIN10Pro: it does not work. Shut down, reboot, nothing. Name is changed in the registry, yes, but in Services display, old name remains. – Echeban Apr 23 at 23:23
  • @Echeban By "Services display" do you mean the name listed in the Services management console (services.msc) main list view? That's the Display Name, not the service name. You can change that either in the registry or using the command line, but it's not the thing the instructions above change. The instructions posted are for changing the service's actual name - not the same as the display name - and I tested it on Windows 10 Enterprise. You can see the actual Service Name in services.msc but only by displaying the details ("Properties") of an individual service. – CBHacking Apr 24 at 1:41

The Windows command line program to change services is "sc".

Here's the Microsoft reference page: https://technet.microsoft.com/en-us/library/bb490995.aspx

To change the display name of a service you can run:

sc config "Old service name" displayname= "New service name"

To change the executable you can run:

sc config "Service name" binpath= "C:\path\to\executable\here"

For both of those commands, make sure you have a space between the = and the new name (ie. displayname= "New Name", NOT displayname="New Name")

| improve this answer | |
  • 1
    If your tomcat uses the monitor program there will be a [oldservicename]w.exe on your drive. Don´t forget to change that name – Marged Sep 22 '15 at 22:45
  • 14
    This changes the service's display name and not the service name. – David Sherret Feb 25 '16 at 18:31
  • 1
    Service name and Display Name are two different things. Display Name, you see it at first glance in the services window. Service name, you have to do Properties to see it. – Sandburg Jun 5 '19 at 7:14
  • sc config "Service" displayname= "My Service" does not work Set-Content : A positional parameter cannot be found that accepts argument 'displayname='. At line:1 char:1 + sc config "Service" displayname= "My Servic ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Content], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand – Echeban Apr 23 at 23:17
  • @Echeban if you are running it in powershell, you need to use sc.exe. – bfhd May 14 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.