Nov 14 2006

Service Path To Executable

Published by at 5:30 pm under General

This is an old article and the information contained within it may be out of date, not reflect my current views and/or contain broken links. If you feel this article is still valid and requires updating, you can use the contact form to let me know. However, I make no guarantee that it will get updated.

Today I’ve been editing and testing a Windows Service application.  I’ve got my system setup so that whilst running in debug mode the application runs as a command line application, so that the debugger automatically connects to it rather than me having to manually connect the debugger to the service every time I want to test my code.

When I switch to Rlease mode the application gets compiled as a service and is automatically started using a post-build action.  This is where I ran into a problem.  Its been a while since I last ran the service on my machine and the release exe location has changed since then and the service starter complained about to path to exe being incorrect.  I could have re-installed the service but I thought it would be easier (and better) to change the location of the currently installed exe.

This is a lot easier than it sounds and can be accomplished with the good ole regedit.  Just click on Start Menu -> Run and enter “Regedit” (sans quotes).  Then you need to navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[Name of Service].  To change the location of the exe just change the ImagePath key.

Please note that directly editing the registry with Regedit can completely balls up your machine and prevent it from starting.  If in doubt seek professional help, so you can blame someone else if it all goes tits-up.

18 responses so far