Solved

Determine what user account a service is running under

Posted on 2009-07-02
3
740 Views
Last Modified: 2012-05-07
Hello I've attached the code I'm using below.  I just grab all the services, and iterate through them.  What I want to do as I iterate through them is this:
.
.
.
For Each mo In queryCollection
    'If userAccount = myUserAccount then
        'Change the password
    'else
        'do nothing

Next
.
.
.

How can I determine what account each service is running under?  Thanks,

Dim ReturnValue As String = String.Empty
        Dim strComputerName As String = "myComputerName"
        Try
 
            Dim query As ManagementObjectSearcher
            Dim queryCollection As ManagementObjectCollection = Nothing
            Dim co As ConnectionOptions
            Dim oq As System.Management.ObjectQuery
            Dim ms As System.Management.ManagementScope
            Dim mo As ManagementObject
            Dim strQuery As String
 
            strQuery = "SELECT * FROM Win32_Service"
            co = New ConnectionOptions
            ms = New System.Management.ManagementScope("\\" + strComputerName + "\root\cimv2", co)
 
            oq = New System.Management.ObjectQuery(strQuery)
            query = New ManagementObjectSearcher(ms, oq)
            Try
                queryCollection = query.Get()
            Catch e1 As Exception
 
            End Try
            For Each mo In queryCollection
 
            Next
 
 
        Catch ex As Exception
 
        End Try

Open in new window

0
Comment
Question by:BobBarker_99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:BobBarker_99
ID: 24766935
I've already read through those pages.  I dont see anything there about determining what account a service is running under.  Am I missing something?
0
 

Accepted Solution

by:
BobBarker_99 earned 0 total points
ID: 24861327
http://www.codeproject.com/KB/cs/WMIforServices.aspx tells you what to pass into the searcher find all services for a specific user.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question