Easier way to debug a Windows service

If I want to quickly debug the service, I just drop in a Debugger.Break() in there. When that line is reached, it will drop me back to VS. Don’t forget to remove that line when you are done. UPDATE: As an alternative to #if DEBUG pragmas, you can also use Conditional(“DEBUG_SERVICE”) attribute. [Conditional(“DEBUG_SERVICE”)] private static … Read more

Install a Windows service using a Windows command prompt?

Navigate to the installutil.exe in your .net folder (for .net 4 it’s C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this: “C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe” “c:\myservice.exe” Regarding a comment, for 64bit apps, use below: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe

“Automatic” vs “Automatic (Delayed start)”

In short, services set to Automatic will start during the boot process, while services set to start as Delayed will start shortly after boot. Starting your service Delayed improves the boot performance of your server and has security benefits which are outlined in the article Adriano linked to in the comments. Update: “shortly after boot” … Read more

Create Windows service from executable

To create a Windows Service from an executable, you can use sc.exe: sc.exe create <new_service_name> binPath= “<path_to_the_service_executable>” You must have quotation marks around the actual exe path, and a space after the binPath=. More information on the sc command can be found in Microsoft KB251192. Note that it will not work for just any executable: … Read more

How do I uninstall a Windows service if the files do not exist anymore?

You have at least three options. I have presented them in order of usage preference. Method 1 – You can use the SC tool (Sc.exe) included in the Resource Kit. (included with Windows 7/8) Open a Command Prompt and enter sc delete <service-name> Tool help snippet follows: DESCRIPTION: SC is a command line program used … Read more

How to solve “The specified service has been marked for deletion” error

There may be several causes which lead to the service being stuck in “marked for deletion”. SysInternals’ Process Explorer is opened. Closing it should lead to automatic removal of the service. Task Manager is opened. Microsoft Management Console (MMC) is opened. To ensure all instances are closed, run taskkill /F /IM mmc.exe. Services console is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)