Login | |
|
 |
Can't figure out this error !!! - 6/19/2006 11:47:47 AM
|
|
 |
|
| |
takeda kozo
Posts: 83
Score: 0
Joined: 11/9/2005
Status: offline
|
Hi All, I am using a script which will look at a user selected folder, and then report all subfolders and files to a text file. The script works fine on smaller directories, but when run on folders which contain many sub folders and files, I get the following error code: Line: 50 Char: 5 Error: 0x80041017 Code: 80041017 Source: (null) I also get a similar error code on Line 78 sometimes as well. I guess it doesn't like my For---Each loops sometimes, for some reason.....UNKNOWN TO ME !!! I've had a bit of a look around, but can't figure out why this error is happening ! Any help or pointers in the right direction would be great ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ strComputer = "." Dim FolderArray SubFolderCount = 0 SubFileCount = 0 Set FSO = CreateObject("Scripting.FileSystemObject") ScriptDir = FSO.GetParentFolderName(WScript.ScriptFullName) Set objOutputFile = FSO.CreateTextFile(ScriptDir & "\Report - Subfolders and Files.txt") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") strFolderName = InputBox("Please enter the root folder" & VbCrLf & VbCrLf & _ "eg: c:\temp","Root Folder","c:\temp",7000,7000) If strFolderName = "" Then WScript.Quit Set colSubfolders = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _ & "Where AssocClass = Win32_Subdirectory " _ & "ResultRole = PartComponent") objOutputFile.WriteLine "-= ROOT FOLDER =- ( " & strFolderName & " )" objOutputFile.WriteBlankLines(2) arrFolderPath = Split(strFolderName, "\") strNewPath = "" For i = 1 to Ubound(arrFolderPath) strNewPath = strNewPath & "\\" & arrFolderPath(i) Next strPath = strNewPath & "\\" Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile where Path = '" & strPath & "'") For Each objFile in colFiles objOutputFile.WriteLine objFile.Name SubFileCount = SubFileCount + 1 Next For Each objFolder in colSubfolders GetSubFolders strFolderName Next Sub GetSubFolders(strFolderName) Set colSubfolders2 = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _ & "Where AssocClass = Win32_Subdirectory " _ & "ResultRole = PartComponent") For Each objFolder2 in colSubfolders2 strFolderName = objFolder2.Name objOutputFile.WriteLine 'Write Subfolder Name strLength = Len(objFolder2.Name) + 2 FolderArray = Split(strFolderName, "\", -1, 1) intSize = UBound(FolderArray) 'WScript.Echo FolderArray(intSize) objOutputFile.WriteLine "/------------------------------------------------\" objOutputFile.WriteLine "| " & FolderArray(intSize) objOutputFile.WriteLine "\------------------------------------------------/" SubFolderCount = SubFolderCount + 1 arrFolderPath = Split(strFolderName, "\") strNewPath = "" For i = 1 to Ubound(arrFolderPath) strNewPath = strNewPath & "\\" & arrFolderPath(i) Next strPath = strNewPath & "\\" Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile where Path = '" & strPath & "'") Written = 0 For Each objFile in colFiles 'Write Subfile Name If Written = 0 Then objOutputFile.WriteBlankLines(1) Written = 1 strFileNameLong = objFile.Name strFileNameShort = Mid(strFileNameLong,strLength) objOutputFile.WriteLine strFileNameShort SubFileCount = SubFileCount + 1 Next GetSubFolders strFolderName Next End Sub MsgBox "Gathering Folder and File Information - Complete. " & VbCrLf & VbCrLf & _ SubFolderCount & " Folders Found" & VbCrLf & _ SubFileCount & " Files Found" & VbCrLf & VbCrLf & _ "(See ''Report - Subfolders and Files.txt'' for details)",64,"Done" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
| |
|
|
|
 |
RE: Can't figure out this error !!! - 6/19/2006 10:32:36 PM
|
|
 |
|
| |
mbouchard
Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
Which is line 50? line 78?
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
|
|