WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Run McAfee VirusScan ASAP


This script runs McAfee VirusScan ASaP on a given drive letter, and emails the result somewhere if the infected count is greater than zero.

McAfee does provide a command line interface, but it sits at a dialog box when it's done, so it does little good if you want to run more than one, or if you would rather see the result in your email.

I was initially trying to parse the HTML dialog that McAfee puts up but ran into some technical snags (thread elsewhere). I later discovered that it creates an HTML report on disk after it finishes. I can detect that report's appearance and manage things from there.

using this program, it's simple to put together a little bat file that runs a few scans, maybe some other housekeeping, and runs from the windows scheduler.

me = StrUpper(FileRoot(IntControl(1004,0,0,0,0)))
Terminate(WinExist(me),"","Only one running at a time please")
BoxTitle(me)
Terminate(param0 < 2, me, "needs disk letter and target emailaddr for HTML report")
BoxText("Controlling McAfee ASaP scanning disk %param1%")
Terminate(WinExist("VSASaP"),me,"VirusScan already running")

                     d = "C:\Windows"
If !DirExist(d) Then d = "C:\WINNT"
If !DirExist(d) Then Exit

pg = StrCat(d, "\myCIO\Agent\HTMLDLG.EXE")

wd = StrCat(d, "\myCIO\VScan\Report\")

se = StrCat(wd,"*.HTM")
sx = StrCat(wd,"*.Xml")

FileDelete(se)  ; tidy up
FileDelete(sx)

If FileItemize(se) > "" Then Terminate(1,me,"cant delete past reports")

pa = ' -Url="myui://ScanNow.htm" -ResDll="myScnUi.Eng" -Param="ScanObject,VT_BSTR,%param1%:\" -Caption="VSASaP %param1%"'

Run(pg,pa)

While 1         ; wait for the HTML report to appear
  TimeDelay(5)
  s = FileItemPath(se)
  If s > "" Then Break
EndWhile
TimeDelay(5)

WinClose("VSASaP")

s = ItemExtract(1,s,@TAB) ; filename of HTML report
b = FileGet(s)

c = StrIndex(b,"Files infected:",1,0)
Terminate(c==0,me,"Cant read report")

c = StrIndex(b,">",c+1,0)
c = StrIndex(b,">",c+1,0)
d = StrIndex(b,"<",c,0)
e = StrSub(b,c+1,d-c-1) ; extract the number of infected files

If e != "0"
    ; substitute your favorite command line emailer here
    Run("wbm.exe",StrCat(param2, " +H", s, " Virus_Scan_", param1))
EndIf

Exit

Article ID:   W16502
File Created: 2005:02:18:12:21:04
Last Updated: 2005:02:18:12:21:04