Thread: Services from LocalHost

  1. #1
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187

    Services from LocalHost

    While trying to get a list of services from localhost...

    An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll

    Additional information: Invalid namespace

    I have the System.Management reference,
    I have also imported the namespace.

    The query is:
    strQuery = "SELECT * FROM Win32_Service"

    //setup
    query = new ManagementObjectSearcher(ms, oq);

    //This line generates the error
    queryCollection = query.Get();

    Ideas?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    I don't see any errors in the information you provided. Maybe a look at this project

    http://www.codeproject.com/useritems/WMI.asp

    might help.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    nvoigt, If your interested it was because of the scope I had written.

    The proper way is:

    ManagementScope scope = new ManagementScope("\\\\localhost\\root\\cimv2", options);

    options is the connection options. Using the default constructor.

    I'm not sure what '\\cimv2' is though

  4. #4
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    Is it possible to get a list of usernames logged in, Full user name and the IP their using ?

    i.e.

    jsmith John Smith 192.168.43.66


    sort of like a network inventory scanner....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. value type v.s. reference type in Web Services
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 07-14-2008, 03:45 AM
  2. basic questions about web services development
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 07-13-2008, 09:30 AM
  3. c++ help needed
    By ettore in forum C++ Programming
    Replies: 17
    Last Post: 01-18-2008, 12:20 PM
  4. Blocking a server with hosts.
    By adrianxw in forum Tech Board
    Replies: 4
    Last Post: 03-14-2003, 12:14 AM