我正在尝试在VBS中编写脚本以显示多个项目的文件属性对话框/表格。这些项目将是父文件夹中的所有项目(例如W:\中的所有项目)。
基本上,我正在尝试获取属性对话框以显示驱动器中的文件数。右键单击驱动器并选择“属性”不会显示文件数。您需要进入驱动器的第一级,选择所有文件夹/文件,然后然后右键单击并选择属性。
我已经在互联网上找到了一些代码(如下所示),可以显示特定文件夹或驱动器的文件属性对话框/表格。我不知道我可以进一步更改以获取指定驱动器的所有文件和文件夹的属性对话框。也许将驱动器的所有文件夹/文件放入一个数组然后使用它?
请注意我正在寻找实际的属性对话框,而不只是简单地返回文件总数(我知道如何做到这一点)。
任何帮助将不胜感激!谢谢:))
代码:
dim objShell, objFSO, folParent, sParent, filTarget, sFileName, sOutput, fivVerbs, iVerb, vVerb, fvbVerb, testItemsParent, TestMappedDestination
set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("Shell.Application")
const mappedDestination = "c:\"
vVerb = "P&roperties"
sParent = objFSO.GetParentFolderName(mappedDestination)
sFileName = objFSO.GetFileName(mappedDestination)
If Len(mappedDestination) = 3 then
nsTarget = &H11
TestMappedDestination = "(" & UCase(Left(mappedDestination,2)) & ")"
Else
nsTarget = sParent
TestMappedDestination = UCase(sFileName)
End If
set folParent = objShell.Namespace(nsTarget)
For each filTarget in folParent.Items
If Len(mappedDestination) = 3 then
testItemsParent = UCase(Right(filTarget,4))
Else
testItemsParent = UCase(filTarget)
End if
If testItemsParent = TestMappedDestination then
Set fivVerbs = filTarget.Verbs
For iVerb = 0 to fivVerbs.Count - 1
If fivVerbs.Item(iVerb).Name = vVerb then
Set fvbVerb = fivVerbs.Item(iVerb)
fvbVerb.DoIt()
filTarget.InvokeVerbEx fvbVerb.Name, ""
Msgbox "Placeholder msgbox to keep properties dialog/sheet from disappearing on script completion"
Exit for
End if
Next
Exit for
End if
Next