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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
@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:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servicesand find the subkey with your service's name.
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
WINADVAPI LSTATUS APIENTRY RegRenameKey( _In_ HKEY hKey, _In_opt_ LPCWSTR lpSubKeyName, _In_ LPCWSTR lpNewKeyName );
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