Home > Software engineering >  WMI find C disk file does not completely
WMI find C disk file does not completely

Time:10-01

Computer configuration: winxp 32-bit, administrator account, file system: NTFS

C this several of the other driver files can be normal lookup,

 Sub WMITest () 
Dim objWMIService As Object
Dim colFiles As Object
Dim objFile As Object

The Set objWMIService=GetObject (winmgmts: \ \ \ "root \ cimv2")

'for each drive root directory file
The Set colFiles=objWMIService. ExecQuery (" Select * from CIM_DataFile where path='\ \' ")
For Each objFile colFiles In
The Debug. Print objFile. The Name 'which shows the C pan-gen 11 files in the directory
Next

All files' access to disk C
The Set colFiles=objWMIService. ExecQuery (" Select * from CIM_DataFile where drive='C:' ")
For Each objFile colFiles In
The Debug. Print objFile. The Name 'only show the 4 C disk file, it's strange
Next

The Set objFile=Nothing
The Set colFiles=Nothing
The Set objWMIService=Nothing
End Sub

CodePudding user response:

Try there, and see if I can get all:
 Sub Test () 
Dim FSO As New FileSystemObject, bFile As File
For Each bFile In FSO. GetFolder (" c: \ "). The Files
The Debug. Print bFile. Name
Next
End Sub

CodePudding user response:

reference 1st floor Topc008 response:
try there, and see if I can get all:
 Sub Test () 
Dim FSO As New FileSystemObject, bFile As File
For Each bFile In FSO. GetFolder (" c: \ "). The Files
The Debug. Print bFile. Name
Next
End Sub



FSO can get normal, WMI with path as a search condition can also be normal, but once the search criteria contains "C:" can't normal access, such as: the where name='C: \ \ test \ \ 1. Doc'
  • Related