I have rewritten the partition section to list the information correctly and eliminate the floppy seek noise. To see the effect of this code, you may have to first delete the system with incorrect partition information from open-audit. For some reason the Open-Audit database retains the information generated by the original partition code.
Add the following function to the bottom of audit.vbs:
[code] Function FixPath(ByRef sPathDisk, ByRef sPathPart) Fixpath = "Win32_LogicalDiskToPartition.Antecedent=" & chr(34) & _ Replace(sPathPart,chr(34), "\" & chr(34)) & chr(34) & "," & _ "Dependent=" & chr(34) & Replace(sPathDisk,chr(34), "\" & _ chr(34)) & chr(34) End Function [/code]
Replace the entire partition section in audit.vbs with the following code:
[code]
''''''''''''''''''''''''''' ' Partition Information ' ''''''''''''''''''''''''''' comment = "Partition Info" if verbose = "y" then wscript.echo comment end if
' Get the LogicalDisk's Path strQueryFields = "DeviceID,Caption,FileSystem,FreeSpace,Size,VolumeName" Set objEnumLogicalDisk = objWMIService.ExecQuery _ ("Select " & strQueryFields & " from Win32_LogicalDisk where DriveType = 3", "WQL", 0) ' Get the DiskPartition's path strQueryFields = "Bootable,BootPartition,DeviceID,DiskIndex,Index,PrimaryPartition" Set objEnumDiskPartition = objWMIService.ExecQuery _ ("Select " & strQueryFields & " from Win32_DiskPartition", "WQL", 0) For Each objDiskPartition in objEnumDiskPartition partition_bootable = objDiskPartition.Bootable if ((partition_bootable <> "True") OR isnull(partition_bootable)) then partition_bootable = "False" end if partition_boot_partition = objDiskPartition.BootPartition if ((partition_boot_partition <> "True") OR isnull(partition_boot_partition)) then partition_boot_partition = "False" end if partition_device_id = objDiskPartition.DeviceID partition_disk_index = objDiskPartition.DiskIndex partition_index = objDiskPartition.Index partition_primary_partition = objDiskPartition.PrimaryPartition For Each objLogicalDisk in objEnumLogicalDisk ' This is expected to fail once in a while since we are ' concatonating a possible path to avoid hitting the floppy On Error Resume Next ' Associate the two sets Set objLogicalDiskToPartition = objWMIService.Get _ (Fixpath(objLogicalDisk.Path_.relpath,objDiskPartition.path_.relpath), 0) If Err.Number = 0 Then 'wscript.echo objLogicalDiskToPartition.path_.relpath splitpath = split(objLogicalDiskToPartition.path_.relpath,"=") LogicalDisk_DeviceID = "" LogicalDisk_DeviceID = splitpath(ubound(splitpath)) LogicalDisk_DeviceID = replace(LogicalDisk_DeviceID,"\","") LogicalDisk_DeviceID = replace(LogicalDisk_DeviceID,"""","") For Each objItem in objEnumLogicalDisk If objItem.DeviceID = LogicalDisk_DeviceID Then partition_caption = objItem.Caption partition_file_system = objItem.FileSystem partition_free_space = 0 partition_free_space = int(objItem.FreeSpace /1024 /1024) partition_size = 0 partition_size = int(objItem.Size /1024 /1024) partition_volume_name = objItem.VolumeName partition_percent = 0 partition_percent = round(((partition_size - partition_free_space) / partition_size) * 100 ,0) form_input = "partition^^^" & partition_bootable & "^^^" & partition_boot_partition & "^^^" _ & partition_device_id & "^^^" & partition_disk_index & "^^^" _ & partition_percent & "^^^" & partition_primary_partition & "^^^" _ & partition_caption & "^^^" & partition_file_system & "^^^" _ & partition_free_space & "^^^" & partition_size & "^^^" _ & partition_volume_name & "^^^" entry form_input,comment,objTextFile,oAdd,oComment form_input = "" Exit For End If Next Else Err.Clear End If On Error Goto 0: Next Next [/code]
|