C# Tradecraft — Unstoppable Service

Tim MalcomVetter
2 min readNov 22, 2018

To be fair, this project (https://github.com/malcomvetter/UnstoppableService) is not perfectly unstoppable (there’s no such thing), but what it does do is demonstrate how simple it is to create a Windows Service in C# that disables the “stop” and “pause” buttons from Service Control Manager (and all other tools that rely on that Windows API call). The service, of course, can still be killed via Task Manager (or similar tools, like Process Explorer pictured below), but you could dress up its metadata to look like a legit service if you’d like (more than what is pictured below):

The only thing required is to set a few flags, which can be seen in the snippet below (sorry about the method name, Weezer had been playing on repeat):

As a side bonus, I added in a code pattern that allows the executable, if run interactively, to automatically install itself as a service. Turns out this is pretty easy to do:

That’s it. The whole example is barely over 100 lines of C#.

Continue to the next post in my C# Tradecraft series.

--

--