Nov 14 2006
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.