Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Moniker

Status
Not open for further replies.

forbsy

MIS
Apr 16, 2002
188
CA
I am totally new to scripting. I've researched how to write a Windows Management Instrumentation(WMI) moniker to check which services on my local machine (that have been set to Automatic) are stopped:

' Listing 9. Code Using an ExecQuery Statement to List Nonrunning Automatic Services

strWMIMoniker = "winmgmts:!//VICKY09"
strQuery = "select * from Win32_Service where State+'Stopped' and StartMode='Auto'"

Set wmiWin32Services = GetObject(strWMIMoniker).ExecQuery(strQuery)
If wmiWin32Services.Count = 0 Then
WScript.Echo "There were no services that matched your query."
Else
For Each wmiWin32Service in wmiWin32Services
WScript.Echo wmiWin32Service.Description
Next
End If

My question is how can I direct the wmiWine32Service.Description to a .txt file? I remember back in the batch file days, I could use the > sign to redirect to a file, but when I tried that in this script I got an error.
I want to be able to capture any services that have been stopped so I can e-mail myself as an alert.
Any help would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top