Uninstall service without reboot in Windows

In my attempt to write TCP/IP application on Windows platform, I realized sometimes it is not possible for your service to uninstall without a reboot of the machine. I imagine this happens most prominently on a multi-user machine, but that is just pure speculation. I have heard that the below is not really needed on a single user machine and instead the services.msc snap in when refreshed can make sure the service is completely removed.

Either way, the method which which you can prevent having to reboot is a two step process:

Determine the PID of your service

sc queryex “NAME_OF_SERVICE”

Here, NAME_OF_SERVICE is the exact name of your service as displayed in the services.msc snap-in on any windows system.

The above command run on the console will output something like:

        TYPE               : 110  WIN32_OWN_PROCESS  (interactive)
        STATE              : 3  STOP_PENDING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x2
        WAIT_HINT          : 0x3e8
        PID                : 6116
        FLAGS              :

In the above output, you want to remember the PID value and proceed to the next step


Use taskkill to force kill your process

taskkill /pid PID /f

After which you should see something like:

SUCCESS: The process with PID 6116 has been terminated.

After this services.msc can be refreshed to reflect a known good state of your service.


I felt this was pretty similar to unix based systems:

ps -ef | grep “Process”

kill -9 PID

Enough to elucidate in this little wordpress post. Hope its of use to someone.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.