Hi, I am a kinda new to VB. I was wondering if I could get an email report of the windows services status (may be a few services) that is running on a remote machine. I wrote the following code with the help of many websites, still getting an error on the sixth line:
strComputer = "computername" Set OutlookApp = CreateObject("Outlook.Application") Set OutLookMail = OutlookApp.CreateItem(0) OutLookMail.To = "firstname.lastname@example.org" OutLookMail.Subject = "Service Report!" Set objSWbemService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colServices = objSWbemService.ExecQuery _ ("SELECT DisplayName,State FROM Win32_Service WHERE Displayname like '%Info%'") For Each objService in colServices OutLookMail.Body = "Wscript.Echo objService.DisplayName & " = " & objService.State" OutLookMail.Send Set OutlookApp = Nothing Set OutLookMail = Nothing Next
Any help is highly appreciated.