Modifying the "Path to executable" of a windows service Modifying the "Path to executable" of a windows service windows windows

Modifying the "Path to executable" of a windows service


It involves editing the registry, but service information can be found in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services. Find the service you want to redirect, locate the ImagePath subkey and change that value.


There is also this approach seen on SuperUser which uses the sc command line instead of modifying the registry:

sc config <service name> binPath= <binary path>

Note: the space after binPath= is important. You can also query the current configuration using:

sc qc <service name>

This displays output similar to:

[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: ServiceName

    TYPE               : 10  WIN32_OWN_PROCESS    START_TYPE         : 2   AUTO_START    ERROR_CONTROL      : 1   NORMAL    BINARY_PATH_NAME   : C:\Services\ServiceName    LOAD_ORDER_GROUP   :    TAG                : 0    DISPLAY_NAME       : <Display name>    DEPENDENCIES       :    SERVICE_START_NAME : user-name@domain-name


You could also do it with PowerShell:

Get-WmiObject win32_service -filter "Name='My Service'" `    | Invoke-WmiMethod -Name Change `    -ArgumentList @($null,$null,$null,$null,$null, `    "C:\Program Files (x86)\My Service\NewName.EXE")

Or:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\My Service" `    -Name ImagePath -Value "C:\Program Files (x86)\My Service\NewName.EXE"