Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Can't figure out this error !!!

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,35555
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Can't figure out this error !!!
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 
 
Post #: 1
 
 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.

(in reply to takeda kozo)
 
 
Post #: 2
 
 RE: Can't figure out this error !!! - 6/20/2006 11:22:01 AM   
  takeda kozo

 

Posts: 83
Score: 0
Joined: 11/9/2005
Status: offline
Hahahaha, are you serious ?

It would have been quicker for you to load the script into an editor (or count the lines) than to post a reply just for that :P

But, as I think you are trying to make a point ..... here you go .....

Line 50: For Each objFolder2 In colSubfolders2

Line 78: For Each objFile In colFiles


Cheers,
TK




(in reply to mbouchard)
 
 
Post #: 3
 
 RE: Can't figure out this error !!! - 6/20/2006 6:57:44 PM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi takeda kozo,

I can speak for myself only, but I feel very serious about identifying error lines (and
complete error messages). If I apply your algorithm to finding the lines, I get
  Line 50: the blank line after "strLength = Len(objFolder2.Name) + 2"
  Line 78: Next
Probably my fault - but how could I correct my mistake? And why should I bother;
you didn't take take your problem seriously enough to google for the error
code and think about contributions like

  http://www.eggheadcafe.com/ng/microsoft.public.scripting.wsh/post21100051.asp

Not laughing,

ehvbs

(in reply to takeda kozo)
 
 
Post #: 4
 
 RE: Can't figure out this error !!! - 6/21/2006 1:34:48 PM   
  takeda kozo

 

Posts: 83
Score: 0
Joined: 11/9/2005
Status: offline
ok, point taken. my apologies

TK

(in reply to ehvbs)
 
 
Post #: 5
 
 RE: Can't figure out this error !!! - 6/22/2006 3:24:20 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
So did you get the problem sorted out? Did you look into the link that ehvbs provided?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to takeda kozo)
 
 
Post #: 6
 
 RE: Can't figure out this error !!! - 10/31/2006 1:01:38 AM   
  pradeepkumar

 

Posts: 2
Score: 0
Joined: 10/30/2006
Status: offline
Hi
I use the following  code to get the memory utilization of process
I some times get the following error at highlighted line
(null): 0x80041017 sometimes only with an NT machine. Refered the links below ,but problem is not solved!!
Set colItems = wbemServices.ExecQuery( "Select TotalVisibleMemorySize from Win32_OperatingSystem")
    if Err.Number Then
    WScript.Echo vbCrLf & "Error # " & _
    " " & Err.Description
    End If
    On Error GoTo 0
    For Each objItem in colItems
    phyMem = objItem.TotalVisibleMemorySize

    Next
    'WScript.Echo "Total:" & phyMem

    On Error Resume Next
    Set colProcItems = wbemServices.ExecQuery( "Select Name,WorkingSetSize,ExecutablePath from Win32_Process")
    if Err.Number Then
    WScript.Echo vbCrLf & "Error # " & _
    " " & Err.Description
    End If
    On Error GoTo 0

    For Each procItem in colProcItems
    WScript.Echo procItem.Name & "  " & " " & -1 & " " & (((procItem.WorkingSetSize \ 1024) * 100) \ phyMem) & "  " & procItem.ExecutablePath
    Next 

(in reply to takeda kozo)
 
 
Post #: 7
 
 RE: Can't figure out this error !!! - 10/31/2006 5:07:07 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi pradeepkumar,

your (very laudable) strategy of locally restricted error handling has a flaw: If
there is a problem with

   Set colItems = wbemServices.ExecQuery( "Select TotalVisibleMemorySize from Win32_OperatingSystem")

you tell about it, but the rest of the code

    For Each objItem in colItems
           ....

doesn't know about it. While a For loop will handle empty collections with no problem, it won't like it, if
colItems isn't a collection (e.g. Null, Empty). So you should bracket code depending on error free
execution of previous statements like this


      

(in reply to pradeepkumar)
 
 
Post #: 8
 
 RE: Can't figure out this error !!! - 11/8/2006 12:21:20 AM   
  pradeepkumar

 

Posts: 2
Score: 0
Joined: 10/30/2006
Status: offline
quote:

Set colProcItems = wbemServices.ExecQuery( "Select TotalVisibleMemorySize from Win32_OperatingSystem")


Hi,
Thanks for correcting me in that.
and i found out the problem for the query returning  NULL ,it was  because  the property "TotalVisibleMemorySize"  was not available in the Windows NT machine.WMI classes and the properties are not the same in all windows systems.When i tried select * from Win32_OperatingSystem for that Windows NT machine.The properties were not the same as the when i tried with an Windows XP machine.
Thanks,
Pradeep

(in reply to ehvbs)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Can't figure out this error !!! Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts