home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileScripts012 < prev    next >
Encoding:
Extensible Markup Language  |  2005-09-02  |  42.4 KB  |  563 lines

  1.  ■<?xml version="1.0" ?>
  2. <package>
  3.     <comment>
  4.         ' *** 
  5.         ' *** ------------------------------------------------------------------------------
  6.         ' *** Filename:        SCTReport.wsf
  7.         ' *** ------------------------------------------------------------------------------
  8.         ' *** Description:    Consolidates Tookit info/files for troubleshooting
  9.         ' *** ------------------------------------------------------------------------------
  10.         ' *** Version:        1.0
  11.         ' *** Notes:        
  12.         ' *** ------------------------------------------------------------------------------
  13.         ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  14.         ' *** ------------------------------------------------------------------------------
  15.         ' ***
  16.     </comment>
  17.     <job>
  18.         <runtime>
  19.             <description>SCT Report</description>
  20.             <named name="Create"                required="false"  many="false"  helpstring="Creates Shared Computer Toolkit Report in C:\SCTReport Directory" />    
  21.             <example>Example: SCTReport.wsf /Create</example>
  22.         </runtime>
  23.         <resource id="CScriptMessage">Restarting script in command-line mode. Run CmdOn.BAT to set command-line mode as the default mode.</resource>
  24.         <resource id="CScriptTitle">Shared Computer Toolkit: Windows Script Mode Detected</resource>
  25.         <?job error="True" debug="False" ?>
  26.         <script language="VBScript" src="../include/Common.vbs"></script>
  27.         <script language="VBScript" src="../include/libWSF.vbs"></script>
  28.         <script language="VBScript" src="../include/clsDiskProtect.vbs"></script>
  29.         <script language="VBScript" src="../include/clsLogging.vbs"></script>
  30.         <script language="VBScript">
  31.         <![CDATA[
  32.             ' ~~~ 
  33.             ' ~~~ Force variables to be declared 
  34.             ' ~~~ 
  35.             Option Explicit
  36.             ' ~~~ Call the Main Sub
  37.             Call Main("NoSCT.hta")
  38.             
  39.             ' ~~~ 
  40.             ' ~~~ Declare variables and constants
  41.             ' ~~~ 
  42.             Dim sAppDir, oDiskProtect
  43.             Dim colItems, oItem
  44.             Dim oOS, colOperatingSystems
  45.             Dim oComputer, colComputers, sDomainJoined
  46.             Dim dtmConvertedDate, dtmInstallDate
  47.             Dim colDrives, oDrive, oText, dateTime
  48.             Dim iPartID, IDiskID, oDisk, oDiskDrives, iTempPart
  49.             Dim oPartition, oDiskPartitions, oLogicalDisk, oLogicalDisks, CalcOVSize, iWDPcmdVer
  50.     
  51.             Dim sPType, bFoundExtended, iPartitionCount, iPartitions, bUnformattedPartition
  52.             Dim iUnallocated, iMaxUnallocated, iExtSize, iUsedSpace, iExtFree, sWindowsDrive, sEscapedDeviceID, iEnd
  53.         
  54.             ' ~~~ Set the WDP.CMD tool version number for SCTReport.WSF
  55.             iWDPcmdVer = 6
  56.     
  57.             ' ~~~ Create Objects
  58.             Set oDiskProtect = New DiskProtect
  59.             Set dateTime    = CreateObject("WbemScripting.SWbemDateTime")
  60.             sAppDir   = RegRead(TOOLKITKEY & "TargetDir")
  61.             If WScript.Arguments.Named.Exists("Create") Then
  62.                 Call DeleteOldProblemDirectory
  63.                 Call CreateNewProblemDirectory
  64.                 Set oText= ofso.OpenTextFile(oShell.ExpandEnvironmentStrings("%SystemDrive%") & "\SCTReport" & "\SCTReport.txt",2,true,-1) 
  65.                 Call GetSCTLogs
  66.                 Call GetWindowsInfo            
  67.                 Call GetWDPInfo
  68.                 Call GetRestrictionsInfo
  69.                 Call DoDirList
  70.             Else
  71.                  WScript.Arguments.ShowUsage
  72.                  QuitScript()
  73.             End If    
  74.             WScript.echo "Report Complete!"
  75.             WScript.echo "Look in "  & oShell.ExpandEnvironmentStrings("%SystemDrive%") & "\SCTReport"    
  76.             oText.Close
  77.             Set oText= Nothing
  78.             
  79.             ' ~~~ Destroy objects
  80.             Set oDiskProtect = Nothing
  81.             UnLoadObjects()
  82.             ' *** 
  83.             ' *** ------------------------------------------------------------------------------
  84.             ' *** Name:            DeleteOldProblemDirectory
  85.             ' *** ------------------------------------------------------------------------------
  86.             ' *** Purpose:        Deletes old report directory
  87.             ' *** ------------------------------------------------------------------------------
  88.             ' *** 
  89.             Sub DeleteOldProblemDirectory
  90.                 Call oShell.Run("CMD /C RD /S /Q %SystemDrive%\SCTReport", 0, True)
  91.             End Sub
  92.             ' *** 
  93.             ' *** ------------------------------------------------------------------------------
  94.             ' *** Name:            CreateNewProblemDirectory
  95.             ' *** ------------------------------------------------------------------------------
  96.             ' *** Purpose:        Creates new report directory
  97.             ' *** ------------------------------------------------------------------------------
  98.             ' *** 
  99.             Sub CreateNewProblemDirectory
  100.                 Call oShell.Run("CMD /C MD %SystemDrive%\SCTReport", 0, True)
  101.                 Call oShell.Run("CMD /C MD %SystemDrive%\SCTReport\Logs", 0, True)
  102.                 Call oShell.Run("CMD /C MD %SystemDrive%\SCTReport\WDP", 0, True)
  103.                 Call oShell.Run("CMD /C MD %SystemDrive%\SCTReport\Restrictions", 0, True)
  104.             End Sub
  105.             ' *** 
  106.             ' *** ------------------------------------------------------------------------------
  107.             ' *** Name:            GetSCTLogs & SCTRegistry
  108.             ' *** ------------------------------------------------------------------------------
  109.             ' *** Purpose:        Gets SCT logs and Registry, and puts them in %SystemDrive%\SCTReport\Logs
  110.             ' *** ------------------------------------------------------------------------------
  111.             ' *** 
  112.             Sub GetSCTLogs
  113.                 Call oShell.Run("CMD /C COPY %WinDir%\System32\Shared_Computer_Toolkit.log %SystemDrive%\SCTReport\Logs", 0, True)
  114.                 Call oShell.Run("CMD /C COPY " & chr(34) & sAppDir & "Log\*.*" & chr(34) & " %SystemDrive%\SCTReport\Logs", 0, True)            
  115.                 
  116.                 Call oShell.Run("REG EXPORT " & chr(34) & Left(TOOLKITKEY,Len(TOOLKITKEY)-1) & chr(34) & " %SystemDrive%\SCTReport\SCTReg.reg.txt", 0, True)            
  117.             End Sub
  118.             ' *** 
  119.             ' *** ------------------------------------------------------------------------------
  120.             ' *** Name:            GetWDPInfo
  121.             ' *** ------------------------------------------------------------------------------
  122.             ' *** Purpose:        Gets WDP relevant info and status
  123.             ' ***                 Records status in %SystemDrive%\SCTReport\SCTReport.txt
  124.             ' ***                 Copies relevant registry settings to %SystemDrive%\SCTReport\WDP
  125.             ' *** ------------------------------------------------------------------------------
  126.             ' *** 
  127.             Sub GetWDPInfo
  128.             
  129.                 Call oShell.Run("REG EXPORT HKLM\SYSTEM\CurrentControlSet\Services\ewf %SystemDrive%\SCTReport\WDP\WDPReg.reg.txt", 0, True)            
  130.                 oText.WriteLine " "
  131.                 oText.WriteLine "***********************"
  132.                 oText.WriteLine "Windows Disk Protection Report"
  133.                 oText.WriteLine "***********************"
  134.                 oText.WriteLine " "
  135.                 If oDiskProtect.Enabled Then
  136.                     oText.WriteLine "WDP: Enabled"
  137.                     oText.WriteLine " "
  138.                     oText.WriteLine " "
  139.                 Else
  140.                     oText.WriteLine "WDP: Disabled"
  141.                     oText.WriteLine " "
  142.                     oText.WriteLine " "
  143.                 End If
  144.                 oText.WriteLine "All Logical Drive Information:"
  145.                 oText.WriteLine " "
  146.                 Set colDrives = oWMIService.ExecQuery _    
  147.                     ("Select * from Win32_LogicalDisk where DriveType =3")
  148.                 For Each oDrive in colDrives
  149.                     oText.WriteLine "Drive letter: " & oDrive.Name
  150.                     oText.WriteLine "Volume name: " & oDrive.VolumeName
  151.                     oText.WriteLine "File system: " & oDrive.FileSystem
  152.                     oText.WriteLine "Total size: " & oDrive.Size
  153.                     oText.WriteLine "Available space: " & oDrive.FreeSpace
  154.                     oText.WriteLine " "
  155.                     oText.WriteLine " "
  156.                     oText.WriteLine " "
  157.                 Next
  158.                 
  159.                 ' ~~~ Determines what physical disk and physical partition contains %WinDir%
  160.                 iDiskID = 0
  161.                 iPartID = 1
  162.                 Set oDiskDrives = oWMIService.ExecQuery("Select * from Win32_DiskDrive")
  163.                 For Each oDisk in oDiskDrives
  164.                     sEscapedDeviceID    = Replace(oDisk.DeviceID, "\", "\\", 1, -1, vbTextCompare)
  165.                     Set oDiskPartitions = oWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & sEscapedDeviceID & """} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
  166.                     For Each oPartition in oDiskPartitions
  167.                     iTempPart = Right(oPartition.DeviceID,1) + 1
  168.                         Set oLogicalDisks = oWMIService.ExecQuery("ASSOCIATORS OF" & "{Win32_DiskPartition.DeviceID=""" & oPartition.DeviceID & """} WHERE AssocClass = Win32_LogicalDiskToPartition")
  169.                         ' ~~~ Collection of logical drives defined on the disk
  170.                         For Each oLogicalDisk In oLogicalDisks
  171.                             If oLogicalDisk.Name = sWindowsDrive then
  172.                                 If IsNumeric(Right(oDisk.Name, 1)) then
  173.                                     iDiskID = Int(Right(oDisk.Name, 1))
  174.                                     iPartID = iTempPart 
  175.                                 End If
  176.                             End If
  177.                         Next
  178.                     Next
  179.                 Next    
  180.                 ' ~~~ Initialize all variables... Critical!
  181.                 CalcOVSize = 0
  182.                 iUnallocated = 0
  183.                 iMaxUnallocated = 0
  184.                 iExtFree = 0
  185.                 iExtSize = 0
  186.                 iUsedSpace = 0
  187.                 iPartitionCount = 0
  188.                 bFoundExtended = False
  189.                 ' ~~~ Loop through all the disk drives
  190.                 For Each oDisk in oDiskDrives
  191.                     If oDisk.Index = iDiskID Then
  192.                         oText.WriteLine "Windows Disk Info: "
  193.                         oText.WriteLine "Size: " & VBTab & VBTab & oDisk.Size
  194.                         oText.WriteLine "Drive Letter: " & VBTab & VBTab & sWindowsDrive
  195.                         oText.WriteLine "Disk #: " & VBTab & VBTab & oDisk.Index 
  196.                         oText.WriteLine "Partition  : " & VBTab & VBTab & iPartID
  197.                         oText.WriteLine 
  198.                         oText.WriteLine "Partition Information: "
  199.                         oText.WriteLine 
  200.                         iPartitions = oDisk.Partitions
  201.                         ' ~~~ New disk, reset the end pointer
  202.                         iEnd   = 0
  203.                         sPType = ""
  204.                                         
  205.                         ' ~~~ Get partitions associated with this disk, we need to escape the device id for the query to work
  206.                         sEscapedDeviceID    = Replace(oDisk.DeviceID, "\", "\\", 1, -1, vbTextCompare)
  207.                         Set oDiskPartitions = oWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & sEscapedDeviceID & """} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
  208.                 
  209.                         ' ~~~ Loop through all the partitions on this disk
  210.                         For Each oPartition in oDiskPartitions
  211.                             '~~~ Count partitions on disk    
  212.                             iPartitionCount = iPartitionCount + 1
  213.                             oText.WriteLine "Partition Name: " & VBTab & oPartition.Name
  214.                             oText.WriteLine "Size: " & VBTab & VBTab & oPartition.Size
  215.                             oText.WriteLine "Type: " & VBTab & VBTab & oPartition.Type
  216.                             oText.WriteLine 
  217.                                                 
  218.                             If sPType <> "Extended w/Extended Int 13" and sPType <> "Extended Partition" Then
  219.                                 If oPartition.Index <> 0 Then
  220.                                     ' ~~~ Calculate the unallocated space before this partition            
  221.                                     iUnallocated = CDbl(oPartition.StartingOffset) - iEnd
  222.                                     If iMaxUnallocated < iUnallocated Then iMaxUnallocated = iUnallocated
  223.                                 End If
  224.                             Else
  225.                         
  226.                                 bFoundExtended = True
  227.                             End If
  228.                             ' ~~~ Notes partition type (Primary or Extended)... do *NOT* move this up!
  229.                             ' ~~~ Moving this line up will affect functionality when last partition is extended. 
  230.                             sPType = oPartition.Type
  231.                             iEnd   = CDbl(oPartition.StartingOffset) + CDbl(oPartition.Size)
  232.                         Next
  233.  
  234.         
  235.                         ' ~~~ Determines if last partition is an Extended Partition
  236.                         If sPType = "Extended w/Extended Int 13" or sPType = "Extended Partition" Then bFoundExtended = True 
  237.                      End If
  238.                 Next
  239.                 oText.WriteLine 
  240.                 oText.WriteLine "Largest Unallocated Space: " & VBTab & iMaxUnallocated
  241.                 ' ~~~ Calculate Free Space in Extended Partition
  242.                 If bfoundExtended = True then
  243.         
  244.                     oText.WriteLine 
  245.                     oText.WriteLine "Extended Partition Info: " 
  246.                     iPartitionCount = 0
  247.                     bUnformattedPartition = False
  248.                     For Each oPartition in oDiskPartitions
  249.                         iPartitionCount = iPartitionCount + 1
  250.                         ' ~~~ Enter only if the partition is extended partition
  251.                         If oPartition.type = "Extended w/Extended Int 13" or oPartition.type = "Extended Partition"  Then
  252.                             iPartitionCount = iPartitionCount - 1
  253.                             ' ~~~ Store the total size of the extended partition
  254.                             iExtsize = oPartition.size
  255.                             ' ~~~ Use partition device id to find logical disk
  256.                             Set oLogicalDisks = oWMIService.ExecQuery("ASSOCIATORS OF" & "{Win32_DiskPartition.DeviceID=""" & oPartition.DeviceID & """} WHERE AssocClass = Win32_LogicalDiskToPartition")
  257.                             ' ~~~ Collection of logical drives in the extended partition
  258.                             For Each oLogicalDisk In oLogicalDisks
  259.                                 oText.WriteLine 
  260.                                 oText.WriteLine "Logical Disk: " & VBTab & oLogicalDisk.Name
  261.                                 oText.WriteLine "Size: " & VBTab & VBTab & oLogicalDisk.Size
  262.             
  263.                                 iPartitionCount = iPartitionCount + 1
  264.                                 If Not(IsNull(oLogicalDisk.size)) then
  265.                                     iUsedSpace = iUsedSpace + oLogicalDisk.size
  266.                                 Else
  267.                                     bUnformattedPartition = True
  268.                                 End If
  269.                             Next
  270.                         End If
  271.                         iExtFree = iExtsize - iUsedSpace
  272.                     Next
  273.                     oText.WriteLine 
  274.                     oText.WriteLine "Free Space: " & VBTab & iExtFree
  275.                     If iPartitionCount < iPartitions or bUnformattedPartition then
  276.                         iMaxUnallocated = 0
  277.                         iExtFree = 0
  278.                     End If
  279.                     If iMaxUnallocated > iExtFree then
  280.                         CalcOVSize = Int(iMaxUnallocated/1024)-1024
  281.                     Else
  282.                         CalcOVSize = Int(iExtFree/1024)-1024
  283.                     End If    
  284.                     ' ~~~ Set to 0 if size req not met
  285.                     If (CalcOVSize < 1047552) or (IsNull(CalcOVSize)) then CalcOVSize = 0
  286.         
  287.                     If CalcOVSize = 0 Then
  288.                         oText.WriteLine 
  289.                         oText.WriteLine "This disk does not appear to support Windows Disk Protection! "
  290.                     End If
  291.                  
  292.                     oText.WriteLine
  293.                 End If
  294.             End Sub
  295.             ' *** 
  296.             ' *** ------------------------------------------------------------------------------
  297.             ' *** Name:            GetRestrictionsInfo
  298.             ' *** ------------------------------------------------------------------------------
  299.             ' *** Purpose:        Records local computer account list in %SystemDrive%\SCTReport\SCTReport.txt
  300.             ' ***                 Copies restriction xml files to %SystemDrive%\SCTReport\Restrictions
  301.             ' *** ------------------------------------------------------------------------------
  302.             ' *** 
  303.             Sub GetRestrictionsInfo
  304.                 oText.WriteLine "***********************"
  305.                 oText.WriteLine "Local Account Report"
  306.                 oText.WriteLine "***********************"
  307.                 Set colItems = oWMIService.ExecQuery _
  308.                     ("Select * from Win32_UserAccount Where LocalAccount = True")
  309.                 For Each oItem in colItems
  310.                     oText.WriteLine "Account Type: " & oItem.AccountType
  311.                     oText.WriteLine "Caption: " & oItem.Caption
  312.                     oText.WriteLine "Description: " & oItem.Description
  313.                     oText.WriteLine "Disabled: " & oItem.Disabled
  314.                     oText.WriteLine "Domain: " & oItem.Domain
  315.                     oText.WriteLine "Full Name: " & oItem.FullName
  316.                     oText.WriteLine "Local Account: " & oItem.LocalAccount
  317.                     oText.WriteLine "Lockout: " & oItem.Lockout
  318.                     oText.WriteLine "Name: " & oItem.Name
  319.                     oText.WriteLine "Password Changeable: " & oItem.PasswordChangeable
  320.                     oText.WriteLine "Password Expires: " & oItem.PasswordExpires
  321.                     oText.WriteLine "Password Required: " & oItem.PasswordRequired
  322.                     oText.WriteLine "SID: " & oItem.SID
  323.                     oText.WriteLine "SID Type: " & oItem.SIDType
  324.                     oText.WriteLine "Status: " & oItem.Status
  325.                     oText.WriteLine " "
  326.                     oText.WriteLine " "
  327.                     oText.WriteLine " "
  328.                 Next
  329.                 Call oShell.Run("CMD /C COPY " & chr(34) & sAppDir & "xml\User*.xml" & chr(34) & " %SystemDrive%\SCTReport\Restrictions", 0, True)
  330.                     
  331.             End Sub
  332.             ' *** 
  333.             ' *** ------------------------------------------------------------------------------
  334.             ' *** Name:            GetWindowsInfo
  335.             ' *** ------------------------------------------------------------------------------
  336.             ' *** Purpose:        Records pertinent system info in %SystemDrive%\SCTReport\SCTReport.txt 
  337.             ' *** ------------------------------------------------------------------------------
  338.             ' *** 
  339.             Sub GetWindowsInfo
  340.                 oText.WriteLine "***********************"
  341.                 oText.WriteLine "Windows Information"
  342.                 oText.WriteLine "***********************"
  343.                 Set colComputers = oWMIService.ExecQuery _
  344.                     ("Select DomainRole from Win32_ComputerSystem")
  345.                 For Each oComputer in colComputers
  346.                     oText.WriteLine " "
  347.                     oText.WriteLine "Computer Name: " & oComputer.Name
  348.                     
  349.                         Select Case oComputer.DomainRole 
  350.                             Case 0 
  351.                                 sDomainJoined = "No"
  352.                             Case 1        
  353.                                 sDomainJoined = "Yes"
  354.                     End Select
  355.                     oText.WriteLine " "
  356.                     oText.WriteLine "Domain Joined: " & sDomainJoined
  357.                     oText.WriteLine " "
  358.                 Next
  359.                 Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
  360.     
  361.                 Set colOperatingSystems = oWMIService.ExecQuery _
  362.                     ("Select * from Win32_OperatingSystem")
  363.                 For Each oOS in colOperatingSystems
  364.                     oText.WriteLine "Boot Device: " & oOS.BootDevice
  365.                     oText.WriteLine "Build Number: " & oOS.BuildNumber
  366.                     oText.WriteLine "Build Type: " & oOS.BuildType
  367.                     oText.WriteLine "Caption: " & oOS.Caption
  368.                     oText.WriteLine "Code Set: " & oOS.CodeSet
  369.                     oText.WriteLine "Country Code: " & oOS.CountryCode
  370.                     oText.WriteLine "Debug: " & oOS.Debug
  371.                     oText.WriteLine "Encryption Level: " & oOS.EncryptionLevel
  372.                     dtmConvertedDate.Value = oOS.InstallDate
  373.                     dtmInstallDate = dtmConvertedDate.GetVarDate
  374.                     oText.WriteLine "Install Date: " & dtmInstallDate 
  375.                     oText.WriteLine "Licensed Users: " & _
  376.                         oOS.NumberOfLicensedUsers
  377.                     oText.WriteLine "Organization: " & oOS.Organization
  378.                     oText.WriteLine "OS Language: " & oOS.OSLanguage
  379.                     oText.WriteLine "OS Product Suite: " & oOS.OSProductSuite
  380.                     oText.WriteLine "OS Type: " & oOS.OSType
  381.                     oText.WriteLine "Primary: " & oOS.Primary
  382.                     oText.WriteLine "Registered User: " & oOS.RegisteredUser
  383.                         oText.WriteLine "Serial Number: " & oOS.SerialNumber
  384.                     oText.WriteLine "Version: " & oOS.Version
  385.                     oText.WriteLine " "
  386.                     oText.WriteLine " "
  387.                     oText.WriteLine " "
  388.     
  389.                 Next
  390.             End Sub
  391.             ' *** 
  392.             ' *** ------------------------------------------------------------------------------
  393.             ' *** Name:            DoDirList
  394.             ' *** ------------------------------------------------------------------------------
  395.             ' *** Purpose:        Directory listing of Toolkit install location
  396.             ' *** ------------------------------------------------------------------------------
  397.             ' *** 
  398.             Sub DoDirList
  399.                 oText.WriteLine "******************************"
  400.                 oText.WriteLine "Installation Directory Listing"
  401.                 oText.WriteLine "******************************"
  402.                 oText.WriteLine " "
  403.                 oText.WriteLine "Toolkit Install Directory: " & sAppDir
  404.                 oText.WriteLine " "
  405.             Dim arrSysFiles, strSysFile
  406.             oText.WriteLine "Creation date          Last accessed          Last modified          Writeable    Size      File"
  407.             ListFolders sAppdir
  408.             ' ~~~ 
  409.             ' ~~~ Iterate through all system32 files.
  410.             ' ~~~ 
  411.             ' ~~~ Create an array of all files in System32
  412.             arrSysFiles = Array("ewf.sys")
  413.             For Each strSysFile in arrSysFiles
  414.                 ListFolder oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\drivers\" & strSysFile, FALSE
  415.             Next
  416.             ' ~~~ End Main
  417.             End Sub
  418.             Sub ListFolders(strAppFolder)
  419.                 Dim oSubFolder, oSubSubFolder
  420.                 ListFolder strAppFolder, TRUE
  421.                 For Each oSubFolder in oFSO.GetFolder(strAppFolder).SubFolders
  422.                         ListFolder oSubFolder.Path, TRUE
  423.                     For Each oSubSubFolder in oSubFolder.SubFolders
  424.                             ListFolder oSubSubFolder.Path, TRUE
  425.                     Next
  426.                 Next
  427.             End Sub
  428.             ' ~~~ List all of the files in strAppFolder, or the single file named by strAppFolder
  429.             Sub ListFolder(strAppFolder, bFolder)
  430.                 Dim colFiles, MyArray, strDrive, strPath, i, oFile
  431.                 ' ~~~ Split strAppFolder into individual folders
  432.                 MyArray = Split(strAppFolder, "\", -1, 1)
  433.             
  434.                 ' ~~~ Surround strDrive and strPath with single quotes for the WMI select statement below
  435.                 strDrive = "'" & MyArray(0) & "'"
  436.                 If bFolder Then
  437.                     strPath  = "'\\"
  438.                 Else
  439.                     strPath  = "'" & MyArray(0) & "\\"
  440.                 End If        
  441.                 ' ~~~ Create strPath with double back-slashes in place of each single back-slash in strAppFolder
  442.                 For i = 1 to UBound(MyArray)
  443.                     strPath = strPath & MyArray(i)
  444.                     If i < UBound(MyArray) Then strPath = strPath & "\\"
  445.                 Next
  446.                 ' ~~~ End strPath with two back-slashes and a single quote for folders, and just a single quote for files.
  447.                 If bFolder Then
  448.                     strPath = strPath & "\\'"
  449.                 Else
  450.                     strPath = strPath & "'"
  451.                 End If        
  452.                 If bFolder Then
  453.                     Set colFiles = oWMIService.ExecQuery("Select * from CIM_DataFile where Drive = " & strDrive & " and Path = " & strPath)
  454.                 Else
  455.                     Set colFiles = oWMIService.ExecQuery("Select * from CIM_DataFile where Name = " & strPath)
  456.                 End If
  457.                 For Each oFile in colFiles
  458.                     DisplayFile(oFile)
  459.                 Next
  460.             End Sub
  461.             ' ~~~ Display the properties of a single file
  462.             Sub DisplayFile(oFile)
  463.                     Dim strCreationDate, strLastAccessed, strLastModified
  464.                     strCreationDate = DateFormat(oFile.CreationDate)
  465.                     strLastAccessed = DateFormat(oFile.LastAccessed)
  466.                     strLastModified = DateFormat(oFile.LastModified)
  467.                     oText.WriteLine strCreationDate & "    " & strLastAccessed & "    " & strLastModified & "    " & oFile.Writeable & "         " & oFile.FileSize & Space(10 - Len(oFile.FileSize)) & oFile.Drive & oFile.Path & oFile.FileName & "." & oFile.Extension
  468.             End Sub
  469.             Function DateFormat(lDate)
  470.                   dateTime.Value  = lDate
  471.                    DateFormat = dateTime.Year & "-" & TwoLong(dateTime.Month) & "-" & TwoLong(dateTime.Day) & " " & TwoLong(dateTime.Hours) & ":" & TwoLong(dateTime.Minutes) & ":" & TwoLong(dateTime.Seconds)
  472.             End Function
  473.             Function TwoLong(iNumber)
  474.                 If iNumber < 10 Then
  475.                     TwoLong = "0" & iNumber
  476.                 ElseIf iNumber = 0 Then
  477.                     TwoLong = "00"
  478.                 Else
  479.                     TwoLong = "" & iNumber
  480.                 End If
  481.             End Function
  482.         ]]>
  483.         </script>
  484.     </job>
  485. </package>