I have a .NET Winddows service which runs under the Local System account. This service then runs a COM component that was written in ATL on Visual Studio 6 using COM Interop. This COM component then runs under the SYSTEM account. I know I can impersonate another account but for now I want to leave things where they are.
The problem is that after the windows service stops, the COM component remains running. I can't kill the process either. Task Manager won't kill it so I tried TaskKill from the command line. This even says it terminated the process successfully but when I check task manager it is still running. I have tried PSKill but that says access denied.
I've exhausted Google looking for a solution to this. Can anyone help?
Also, why does it remain running anyway?
Killing a process is just a matter of permissions. Assuming Vista/7 with UAC on, you won't be able to kill a system process if you're not running as an administrator. Note - it's not enough to be a member of the local administrators group. You must launch task manager / process explorer / pskill or whatever using "Run As Administrator" to actually run them with administrative permissions. Otherwise, you're just a regular user, and you're denied.
As for the COM server sticking around: COM servers have a reference count, and they shut themselves down only after the count drops to 0. In your case, the server might not shut down due to a few reasons: