Introduction
All Windows service running on the computer has their own executable path called binPath. Here in this article Change Executable Path of Services in Windows 11 Pro, we would demonstrate how to change the path of executable (binPath) of a Windows service using a Computer Registry and Command Prompt.
Change Executable Path of Services in Windows 11 Pro |
Getting Started
As a developer, everyone must have worked with Windows service. When a Windows service is installed, the information (like the location of services in the computer etc.) of the services is stored in the computer registry. That path can be changed using the Registry Windows and Command Prompt. In below we will demonstrate how to change the executable path using both mentioned approaches.
We will discuss here the SQL service which I installed during the window installation. Note that during the demonstration do not change the path other wise you will get into trouble.
Change Executable Path of Services Using Registry Editor
The following steps will guide you in checking registry to see/ change the executable path of the SQL service.
- Press Windows+ 'R' key at a time, the run window will be open then type 'regedit'.
- Or in search type 'registry editor'.
- The Registry Editor window will be open then find the 'HKEY_LOCAL_MACHINE' and expand it.
- Go to the system=> CurrentControlSet=>Services key.
- Find the name of your Windows service whose executable path you want to change and select, here we will see the path of SQL Angen, hence I have selected the SQLAgent$SQLExpress.
- On the right pan, you will get different keys, find the ImagePath and double-click on it.
- The ImagePath is the path of the executable file of services. here you can change your service location.
Change Executable Path of Services Using Command Prompt
The above steps helped to see/ change the executable path of services, following steps will guide you to change the executable path of SQL service using cmd commands.
- Run the command prompt in admin mode.
- To run the command prompt type 'cmd' in the window search field and click 'Run as administrator'.
- Run the sc command in the command prompt.
- Replace the <service name> with your service name.
- Replace the <binary path> with the path of your executable files.
- Examples;-
- using the qc sc command, we can see the current configuration of the window service also. Syntax
- Example:-
//Syntax
sc config <service name> binPath= <binary path>
sc config SQLAgent$SQLEXPRESS binPath="C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\Binn\SQLAGENT.EXE" -i SQLEXPRESS"
sc qc <Service Name>
sc qc SQLAgent$SQLEXPRESS
Change Executable Path of Services in Windows 11 Pro
It's also probably a bit nicer in a deployment script than the direct registry modification approach. I would recommend this approach over direct registry changes.
Thanks