Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C#:How do you kill an application when all you have is the GUID?

Back to Forum: Tech Off
  • User profile image
    lagu26537

    It's a VPN client and the shortcut references a GUID/registry key/CLSID
    {c3a78f90-b4a7-12cd-b979-080a2b30b5eb} I've tried to find an application reference with regedit without success.

    How do you kill it in C# when all you have is the GUID/registry key/CLSID?

  • User profile image
    Richard.Hein

    You might start with WMI to find the name of the .dll or .exe you want from the component Id, using System.Management, I made a managed class wrapper around Win32_ClassicCOMClassSetting and did this:

    ROOT.CIMV2.ClassicCOMClassSetting.ClassicCOMClassSettingCollection comClasses = ROOT.CIMV2.ClassicCOMClassSetting.GetInstances("ComponentId = \"{0D81DFEC-5610-4A2B-9B57-FC33D21366F0}\"");

    foreach (ROOT.CIMV2.ClassicCOMClassSetting comClass in comClasses)

    {

    Console.WriteLine("AppId= " + comClass.AppID + "\nComponentId= " + comClass.ComponentId + "\nInProcServer= " + comClass.InprocServer + "\nInProcServer32=" + comClass.InprocServer32 + "\nLocalServer=" + comClass.LocalServer + "\nLocalServer32=" + comClass.LocalServer32);

    Console.ReadKey();

    }

    Which gives me:

    AppId= {0D81DFEC-5610-4A2B-9B57-FC33D21366F0}
    ComponentId= {0D81DFEC-5610-4A2B-9B57-FC33D21366F0}
    InProcServer=
    InProcServer32=
    LocalServer=
    LocalServer32=J:\PROGRA~1\MSNMES~1\msnmsgr.exe

    Which then can be used to find the process id and kill it. 

    To create the managed class wrapper, if you haven't before, you just navigate in the Server Explorer in Visual Studio, to Servers/Management Classes, right-click, Properties, Add Classes, look under Root/CIMV2 and find and add ClassicCOMClassSetting, then when it's added, right-click on Classic COM Class Settings and select Generate Managed Class, which creates the wrapper for you.

    Warning:  Expanding the Classic COM Class Settings node will take all day to enumerate all the components; it's best to avoid it, and go through DCOM Application Settings or something else that has Classic COM Class Settings as a child for whatever DCOM  apps derive from it.

    One more thing ... note that you may have to drill down through multiple components to find the server hosting your component.

    HTH

  • User profile image
    lagu26537

    All I have in my server explorer are 6 SQL servers. How do you connect to WMI in server explorer?

  • User profile image
    Richard.Hein

    It should be there in Visual Studio 2005, so I assume you are using VS.NET 2003, in which case you need to download and install the Management (WMI) Extensions for Visual Studio .NET 2003 Server Explorer, available at:

    http://www.microsoft.com/downloads/details.aspx?familyid=62d91a63-1253-4ea6-8599-68fb3ef77de1&displaylang=en

  • User profile image
    lagu26537

    No I'm using VS 2005. The only thing in server explorer is an item at the top that says "Data Connections". If I right click it and choose "Add connection" a window with the title "Choose Data Source" pops up. In that window there are 6 SQL servers and an <other> item.

  • User profile image
    lagu26537

    Also the network technician told me the exe is probably svchost.exe. Now I need to unload a dll which I think I know the name of from svchost.exe. How do you do that?

  • User profile image
    Richard.Hein

    lagu26537 wrote:
    No I'm using VS 2005. The only thing in server explorer is an item at the top that says "Data Connections". If I right click it and choose "Add connection" a window with the title "Choose Data Source" pops up. In that window there are 6 SQL servers and an <other> item.


    Hmm ... which version of VS 2005 are you using?  It should be there AFAIK, maybe it's an optional component to install?

    You can do it without the tool - but you have to write a little bit more code.  Take a look at this documentation:

    http://msdn2.microsoft.com/en-us/library/ms186120(VS.80).aspx">http://msdn2.microsoft.com/en-us/library/ms186120(VS.80).aspx, in there you'll find a lot of information about it and especially at http://msdn2.microsoft.com/en-us/library/ms186146(VS.80).aspx">http://msdn2.microsoft.com/en-us/library/ms186146(VS.80).aspx where there's a sample of a query ... you want to "SELECT * FROM Win32_COMSetting WHERE ComponentId=yourGUID"

    Win32_ComSetting is documented here: http://msdn2.microsoft.com/en-us/library/aa394107.aspx



  • User profile image
    Richard.Hein

    lagu26537 wrote:
    Also the network technician told me the exe is probably svchost.exe. Now I need to unload a dll which I think I know the name of from svchost.exe. How do you do that?


    If it's always the same dll, then you can find out which host it's in by using Component Services/Computer/My Computer/DCOM and finding your GUID, take a look at the properties, etc....

    If svchost is your host, is it a Windows Service?  Then you just kill the service, using System.ServiceProcess.ServiceController. 

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.