Solved

Look for automatic services that contain a specific keyword, tag them and add to each line a string only using VBS

Posted on 2015-02-22
2
72 Views
Last Modified: 2015-02-22
I need a script in VBS to pull out all automatic services that contain a keyword McAfee... and add to each line the string (            Av      1      *      0000 2400) and put them under two tags [Antivirus],[McAfee]:

Each service should be into double quotes as in below example:

[Antivirus],[McAfee]
"McAfee Host Intrusion Prevention Service"            Av      1      *      0000 2400
"McAfee Host Intrusion Prevention lpc Service"            Av      1      *      0000 2400
"McAfee McShield"            Av      1      *      0000 2400
0
Comment
Question by:acunaara
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40624638
Hi, I think this should do what you're after:
strOutput = "McAfeeServices.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutput = objFSO.CreateTextFile(strOutput, True)
objOutput.WriteLine "[Antivirus],[McAfee]"
strComputer = "."
Set colServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2").ExecQuery("SELECT * FROM Win32_Service WHERE StartMode='Auto' AND Caption LIKE '%McAfee%'")
For Each objService In colServices
	objOutput.WriteLine """" & objService.Caption & """           Av      1      *      0000 2400"
Next
objOutput.Close
WScript.Echo "Done. Please see " & strOutput

Open in new window


Regards,

Rob.
0
 

Author Closing Comment

by:acunaara
ID: 40625046
Exactly what i need. Thanks!!
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

827 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