'************************************************************************
' VARIABLE DEFINITION
'************************************************************************
strFilePath = "\Program Files\Anti Virus\av.exe"
[red]
set objArgs = Wscript.Arguments
set objCommand = CreateObject("ADODB.Command")
set objConnection = CreateObject("ADODB.Connection")
set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
set objRootDSE = GetObject("LDAP://RootDSE")
set objShell = WScript.CreateObject("WScript.Shell")
[/red]
'************************************************************************
' BEGIN
'************************************************************************
[COLOR=#008080]
set objOutput = objFSO.OpenTextFile("c:\temp\results.csv", 2, true, 0)
objOutput.WriteLine "Computer,Status"
[/color]
[red]
strDNSDomain = objRootDSE.Get("defaultNamingContext")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Timeout") = 30
objCommand.Properties("Page Size") = 100
objCommand.Properties("Cache Results") = False
objCommand.CommandText = "SELECT sAMAccountName FROM 'LDAP://" & strDNSDomain & "' WHERE objectCategory='computer'"
set objRecordSet = objCommand.Execute
[/red]
[blue]
do until objRecordSet.EOF
strComputer = objRecordset.Fields("sAMAccountName").Value
strComputer = left(strComputer, len(strComputer) - 1)
[green]
on error resume next
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
if (Err.number = 0) then
on error goto 0
[purple] set colDisks = objWMI.ExecQuery("Select * From Win32_LogicalDisk")
boolFileExists = false
for each objDisk in colDisks
strPath = objDisk.Name & strFilePath
if (objFSO.FileExists(strPath)) then
objOutput.WriteLine strComputer & "," & strPath
boolFileExists = true
end if
next
[/purple] if (boolFileExists = false) then
[COLOR=#008080] objOutput.WriteLine strComputer & ",File Does Not Exist"[/color]
end if
else
[COLOR=#008080] objOutput.WriteLine strComputer & ",Computer not accessible"[/color]
end if
[/green] objRecordSet.MoveNext
loop
[/blue]
[COLOR=#008080]
objOutput.close
[/color]
msgbox "done"