[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
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
Medium Priority
?
84 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

873 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