Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desperate for debugging of very short script using GetDetailsOf and ParseName

Status
Not open for further replies.

billbrasky

Technical User
May 17, 2012
5
I'm a humble guy. I'm far from being a VBScript guru, but I always try to do my own research and solve my own problems. I hardly ever ask people for help, but I've been working on this ONE problem for two solid days now, and I'm rapidly becoming a danger to myself and others. I come to you all because I now surrender. You win, VBScript. It's a pretty short script, but I simply don't understand why it won't work.

This command-line script remotely enumerates all folders (along with some folder properties) within a specified path.

For example, if this script was named myscript.vbs, and you had a remote workstation on your network called Icebox, and it had a local folder with the path of C:\Common, the command-line synax would be:
C:\> myscript.vbs Icebox c:\common

Here's the code:

' Converts arguments from Icebox c:\common to \\icebox\c$\common
strPath = "\\" & WScript.Arguments(0) & "\" & Replace(WScript.Arguments(1),":","$")
' The subroutine below is called
ShowFolderDetails strPath

Sub ShowFolderDetails(strPath)
Set objFSOFolder = CreateObject("Scripting.FileSystemObject").GetFolder(strPath)
Set objShellFolder = CreateObject("Shell.Application").Namespace(strPath)
' The following line indents and prints a preceding \ to the relative path
WScript.Echo Space(UBound(Split(objFSOFolder.Path,"\"))-3) & "\" & _
objFSOFolder.Name & " - " & _
FormatNumber(objFSOFolder.Size/1000,0) & "k" & _
", Owner: " & objShellFolder.GetDetailsOf(objShellFolder.ParseName(objShellFolder.Title),10) & _
", Last Accessed: " & objFSOFolder.DateLastAccessed
' The loop below iterates through each subfolder, this subroutine recursively calls itself as needed
For Each Subfolder in objFSOFolder.Subfolders
ShowFolderDetails Subfolder.Path
Next
End Sub

The problem is with the line in bold. When I manually substitute in a value for objShellFolder.Title (such as "testfolder"), it works fine for that one folder. When I switch it to a variable that I've confirmed contains that same correct string value, it just won't work. It outputs the file's extended property name instead of it's value (it outputs the word "Owner" instead of Icebox\LocalAdmin).

ParseName needs to accept a variable because the script is on a loop and it's the only way to output the data. ParseName simply won't work when it's fed a variable. I've wasted so much time trying to code around it, and I'm coming apart over here. Please help.

Desperately,
Bill
 
What about this ?
", Owner: " & objShellFolder.GetDetailsOf(objShellFolder.ParseName([!]objFSOFolder.Name[/!]),10) & _

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, your input is greatly appreciated! Unfortunately, it made no difference... I get the same results...
 
Thanks to all those who helped, and even those who read this thread hoping they could help.

For all those like myself who spent hours searching for the answer to this problem, the solution lies in the knowledge that the GetDetailsOf method can ONLY get the details of items WITHIN the object, but cannot get details of the object itself. Hope this post eventually helps somebody stuck in the same predicament I was...
 
Actually, on second thought, I think I meant ParseName not GetDetailsOf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top