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
68 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
Comment Utility
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
Comment Utility
Exactly what i need. Thanks!!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now