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
76 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

707 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