From: LikeToCode on 8 Feb 2010 00:52 Will this work for you? You could add an "Input Box" to this script to charge the variable "strDomain" with what ever domain you will be running it in.\ Option Explicit Dim objWMIService, colServices, objFSO, objTS, objService, strComputer, strDomain strDomain = "MYDOMAIN" strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" & strComputer & "\root\cimv2") Set colServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTS = objFSO.CreateTextFile("C:\Services.txt") objTS.WriteLine "........................................................" objTS.WriteLine "....................SERVICES RUNNING...................." objTS.WriteLine "........................................................" objTS.WriteBlankLines(2) For Each objService in colServices If objService.StartName = ".\Administrator" Then objTS.WriteLine "Service name: " & objService.Displayname objTS.WriteLine "Start Mode: " & objService.StartMode objTS.WriteLine "Service State: " & objService.State objTS.WriteLine "Credentials: " & objService.StartName objTS.WriteBlankLines(2) ElseIf objService.StartName = strDomain & "\Administrator" Then objTS.WriteLine "Service name: " & objService.Displayname objTS.WriteLine "Start Mode: " & objService.StartMode objTS.WriteLine "Service State: " & objService.State objTS.WriteLine "Credentials: " & objService.StartName objTS.WriteBlankLines(2) End If Next objTS.Close() Set objFSO = Nothing Set colServices = Nothing
From: Cary Shultz on 8 Feb 2010 05:26 LikeToCode, Normally, yes - it would work....Thank you for the tip. But, we install a small piece of software on all of the machines (servers and workstations) that we manage and we have a "Scripting" center which allows us to upload scripts that can then be run against all machines (if desired). Thus, the need for a generic script that does not require specifics (we manage a lot of environments...). Thanks, Cary "LikeToCode" <LikeToCode(a)discussions.microsoft.com> wrote in message news:D6E563D4-243D-48E7-A55B-EE86F846DBA4(a)microsoft.com... > Will this work for you? You could add an "Input Box" to this script to > charge > the variable "strDomain" with what ever domain you will be running it in.\ > > Option Explicit > Dim objWMIService, colServices, objFSO, objTS, objService, strComputer, > strDomain > strDomain = "MYDOMAIN" > strComputer = "." > > Set objWMIService = > GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" > & strComputer & "\root\cimv2") > Set colServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service") > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objTS = objFSO.CreateTextFile("C:\Services.txt") > > objTS.WriteLine "........................................................" > objTS.WriteLine "....................SERVICES RUNNING...................." > objTS.WriteLine "........................................................" > objTS.WriteBlankLines(2) > > For Each objService in colServices > If objService.StartName = ".\Administrator" Then > objTS.WriteLine "Service name: " & objService.Displayname > objTS.WriteLine "Start Mode: " & objService.StartMode > objTS.WriteLine "Service State: " & objService.State > objTS.WriteLine "Credentials: " & objService.StartName > objTS.WriteBlankLines(2) > ElseIf objService.StartName = strDomain & "\Administrator" Then > objTS.WriteLine "Service name: " & objService.Displayname > objTS.WriteLine "Start Mode: " & objService.StartMode > objTS.WriteLine "Service State: " & objService.State > objTS.WriteLine "Credentials: " & objService.StartName > objTS.WriteBlankLines(2) > End If > Next > objTS.Close() > Set objFSO = Nothing > Set colServices = Nothing
From: LikeToCode on 8 Feb 2010 08:53 Try replacing your query statement with the following. Set colServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE StartName LIKE '%Administrator'",,48)
From: Cary Shultz on 8 Feb 2010 09:49 That did it....thank you very much. I just learned something today.... "LikeToCode" <LikeToCode(a)discussions.microsoft.com> wrote in message news:29361D02-90DA-487C-A1BD-D4A5D0D497C1(a)microsoft.com... > Try replacing your query statement with the following. > > Set colServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service > WHERE > StartName LIKE '%Administrator'",,48) > >
From: LikeToCode on 8 Feb 2010 10:28
WMI queries can use limited SQL syntax. Sorry my first post was off base, it was late and post Super Bowl. I should have gone to bed!! -- "Wisdom is the reward you get for a lifetime of listening when you'd rather have been talking." – Aristotle |