?
Solved

Determine what user account a service is running under

Posted on 2009-07-02
3
Medium Priority
?
742 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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