'******************************************************************************** ' NS7 Custinv to scan for exe & pst files by quering the cim_datafile wmi class ' Written 26 October 2009 '******************************************************************************** 'Create instance of Wbem service object, connect to namespace and run wmi query strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") '=================================================================================================================== 'Create instance of Altiris NSE component dim nse set nse = WScript.CreateObject ("Altiris.AeXNSEvent") ' Set the header data of the NSE ' Please don't modify this GUID nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}" nse.Priority = 1 'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server dim objDCInstance set objDCInstance = nse.AddDataClass ("CimDataFile") dim objDataClass set objDataClass = nse.AddDataBlock (objDCInstance) cnt=0 Set objCIMDrive = objWMIService.ExecQuery("select * from Win32_LogicalDisk where description = 'Local Fixed Disk'") For each objDrive in objCIMDrive driveletter=objDrive.DeviceId cnt = cnt + 1 Set objCIMObj = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile where Drive='" & driveletter & "' and (Extension='exe' or Extension='pst')") For each objInfo in objCIMObj validFile = 1 testPath = objInfo.Path 'pathPos = inStr(testPath,"program files") 'if pathPos > 0 then validFile = 0 End If pathPos = inStr(testPath,"windows") if pathPos > 0 then validFile = 0 End If pathPos = inStr(testPath,"System Volume") if pathPos > 0 then validFile = 0 End If pathPos = inStr(testPath,"recycle") if pathPos > 0 then validFile = 0 End If pathPos = inStr(testPath,"temp") if pathPos > 0 then validFile = 0 End If if validFile then 'Add a new row dim objDataRow set objDataRow = objDataClass.AddRow 'Set columns objDataRow.SetField 0, ToXmlString(objInfo.CreationDate) objDataRow.SetField 1, ToXmlString(objInfo.Drive) objDataRow.SetField 2, ToXmlString(objInfo.Extension) objDataRow.SetField 3, ToXmlString(objInfo.FileName) objDataRow.SetField 4, ToXmlString(objInfo.FileSize) objDataRow.SetField 5, ToXmlString(objInfo.InstallDate) objDataRow.SetField 6, ToXmlString(objInfo.LastModified) objDataRow.SetField 7, ToXmlString(objInfo.Name) objDataRow.SetField 8, ToXmlString(objInfo.Path) End If Next Next ' Send the NSE data to the NS server nse.SendQueued ''' End of vbscript main logic Function ToXmlString (strInput) Dim strOutput If (IsNull(strInput)) Then ToXMLString = strInput Else strOutput = Replace(strInput, "&", "&") strOutput = Replace(strOutput, """", """) strOutput = Replace(strOutput, "<", "<") ToXmlString = Replace(strOutput, ">", ">") End If End Function