Welcome to EMC Consulting Blogs Sign in | Join | Help

Stuart Preston's Blog

Stuart was CTO for Application Consulting EMEA at EMC Consulting until October 2009, now blogging at http://stuartpreston.net

Getting the account name for a given service using WMI, VBScript

More code that I've hacked together in VBScript to get the username used to start a particular service on my system:

Dim objWMIService, objService, strServiceStartName
Dim colListOfServices, strService

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service where name = 'MSSQLSERVER'")

For Each objService in colListOfServices
    strServiceStartName = Trim(objService.StartName)
Next

wscript.echo strServiceStartName

Published 14 November 2005 18:36 by Stuart.Preston

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

I have now left EMC Consulting and can be found at http://stuartpreston.net
Powered by Community Server (Personal Edition), by Telligent Systems