vbscript - How do I ignore Windows Defender when calling SecurityCenter2? -
i'm working on script detect whether or not there antivirus solution running on windows machine. when running on windows 8 i'm getting false positives antivirus disabled when running third party av solution due windows defender being around although disabled. can see productstate third party av valid , reporting correctly, script pulling windows defender entries. need keep entries windows defender, i'm interested in windows defender if there no other antivirus installed. ran following command command prompt retrieve data, shows 2 separate entries.
wmic /node:localhost /namespace:\\root\securitycenter2 path antivirusproduct /format:list i grab third party antivirus if it's installed, otherwise keep windows defender information.
how i'm trying calling instanceguid , compare against windows defender guid, i'm getting few false positives. there anyway me parse data correctly , ideally @ third party information? i'm including full script show i'm looking at, can cut down if needed
set objwmiservicesc = getobject("winmgmts:\\.\root\securitycenter2") set colavitems = objwmiservicesc.execquery("select * antivirusproduct") each objantivirusproduct in colavitems strinstanceguid = (objantivirusproduct.instanceguid) strwindefguid = "{d68ddc3a-831f-4fae-9e44-da132c1acf46}" if strinstanceguid <> strwindefguid avstatus = hex(objantivirusproduct.productstate) if (objantivirusproduct.productstate = "393472" _ or mid(avstatus, 2, 2) = "10" or mid(avstatus, 2, 2) = "11" _ or mid(avstatus, 5, 2) = "10" or mid(avstatus, 5, 2) = "11") strproductstate = "enabled" else strproductstate = "disabled" end if else if mid(avstatus, 2, 2) = "10" or mid(avstatus, 2, 2) = "11" _ or mid(avstatus, 5, 2) = "10" or mid(avstatus, 5, 2) = "11" strproductstate = "enabled" else strproductstate = "disabled" end if end if if mid(avstatus, 4, 2) = "00" strdefinitionstate = "current" elseif mid(avstatus, 4, 2) = "10" strdefinitionstate = "outdated" end if next just reiterate, windows 8 issue.
i found solution issue. ended putting if statement before statement looking @ how many entries in security center wmi antivirus. if there 0 reports none, if there 1 installed reads info, , if there more 1 ignores windows defender , reads rest. i'm including full code future users.
dim objwmiservicesc,objantivirusproduct,colavitems,avstatus set objwmiservicesc = getobject("winmgmts:\\.\root\securitycenter2") set colavitems = objwmiservicesc.execquery("select * antivirusproduct") if colavitems.count = 0 strdisplayname = "no" errors("acceptable antivirus software found ") = "no" elseif colavitems.count = 1 each objantivirusproduct in colavitems strdisplayname = (objantivirusproduct.displayname) avstatus = hex(objantivirusproduct.productstate) if (objantivirusproduct.productstate = "266240" _ or objantivirusproduct.productstate = "331776" _ or objantivirusproduct.productstate = "397568" _ or mid(avstatus, 2, 2) = "10" or mid(avstatus, 2, 2) = "11" _ or mid(avstatus, 5, 2) = "10" or mid(avstatus, 5, 2) = "11") strproductstate = "enabled" else strproductstate = "disabled" errors("antivirus scanning ") = "disabled" end if if mid(avstatus, 4, 2) = "00" strdefinitionstate = "current" elseif mid(avstatus, 4, 2) = "10" strdefinitionstate = "outdated" errors("antivirus definitions ") = "outdated" end if next elseif colavitems.count > 1 each objantivirusproduct in colavitems if (objantivirusproduct.displayname) <> "windows defender" strdisplayname = (objantivirusproduct.displayname) avstatus = hex(objantivirusproduct.productstate) if (objantivirusproduct.productstate = "393472" _ or objantivirusproduct.productstate = "266240" _ or objantivirusproduct.productstate = "331776" _ or objantivirusproduct.productstate = "397568" _ or mid(avstatus, 2, 2) = "10" or mid(avstatus, 2, 2) = "11" _ or mid(avstatus, 5, 2) = "10" or mid(avstatus, 5, 2) = "11") strproductstate = "enabled" else strproductstate = "disabled" errors("antivirus scanning ") = "disabled" end if if mid(avstatus, 4, 2) = "00" strdefinitionstate = "current" elseif mid(avstatus, 4, 2) = "10" strdefinitionstate = "outdated" errors("antivirus definitions ") = "outdated" end if end if next end if
Comments
Post a Comment