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
71 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

831 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