SQLScholar
Programmer
Hey all,
I have written (borrowed large bits!) a script which is supposed to output the directory structure of the current directory to a text file. Please see below script:
Now it seems to work - other then it ends too quickly. It gets half way through documents and settings and stops (i.e. finishes doing that last loop.).
Cant see for the life of me why?
Can anyone sugguest?
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have written (borrowed large bits!) a script which is supposed to output the directory structure of the current directory to a text file. Please see below script:
Code:
On Error Resume Next
Dim arrFolders()
intSize = 0
strComputer = "."
strPath = Wscript.ScriptFullName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder2 = objFSO.GetParentFolderName(objFile)
strFolderName = strFolder2
GetSubFolders strFolderName
Sub GetSubFolders(strFolderName)
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
strFolderName = objFolder.Name
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1
GetSubFolders strFolderName
Next
End Sub
set outputfile = objFSO.OpenTextFile("DirectoryFilestructure.txt", 8, True)
For Each strFolder in arrFolders
outputfile.writeline(strFolder)
Next
outputfile.close
Now it seems to work - other then it ends too quickly. It gets half way through documents and settings and stops (i.e. finishes doing that last loop.).
Cant see for the life of me why?
Can anyone sugguest?
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------