Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Win32_Directory class

The Win32_Directory WMI class represents a directory entry on a computer system running Windows. A directory is a type of file that logically groups data files and provides path information for the grouped files. Example: C:\TEMP. Win32_Directory does not include directories of network drives.

The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties are listed in alphabetic order, not MOF order.

Syntax

[Provider("CIMWin32")]class Win32_Directory : CIM_Directory
{
  uint32   AccessMask;
  boolean  Archive;
  string   Caption;
  boolean  Compressed;
  string   CompressionMethod;
  string   CreationClassName;
  datetime CreationDate;
  string   CSCreationClassName;
  string   CSName;
  string   Description;
  string   Drive;
  string   EightDotThreeFileName;
  boolean  Encrypted;
  string   EncryptionMethod;
  string   Extension;
  string   FileName;
  uint64   FileSize;
  string   FileType;
  string   FSCreationClassName;
  string   FSName;
  boolean  Hidden;
  datetime InstallDate;
  uint64   InUseCount;
  datetime LastAccessed;
  datetime LastModified;
  string   Name;
  string   Path;
  boolean  Readable;
  string   Status;
  boolean  System;
  boolean  Writeable;
};

Members

The Win32_Directory class has these types of members:

Methods

The Win32_Directory class has these methods.

MethodDescription
ChangeSecurityPermissions

Class method that changes the security permissions for the logical file specified in the object path.

ChangeSecurityPermissionsEx

Class method that changes the security permissions for the logical file specified in the object path.

Compress

Class method that compresses the logical file (or directory) specified in the object path.

CompressEx

Class method that compresses the logical file (or directory) specified in the object path.

Copy

Class method that copies the logical file or directory specified in the object path to the location specified by the input parameter.

CopyEx

Class method that copies the logical file or directory specified in the object path to the location specified by the FileName parameter.

Delete

Class method that deletes the logical file (or directory) specified in the object path.

DeleteEx

Class method that deletes the logical file (or directory) specified in the object path.

GetEffectivePermission

Class method that determines whether the caller has the aggregated permissions specified by the Permissions argument not only on the file object, but on the share the file or directory resides on (if it is on a share).

Rename

Class method that renames the logical file (or directory) specified in the object path.

TakeOwnerShip

Class method that obtains ownership of the logical file specified in the object path.

TakeOwnerShipEx

Class method that obtains ownership of the logical file specified in the object path.

Uncompress

Class method that uncompresses the logical file (or directory) specified in the object path.

UncompressEx

Class method that uncompresses the logical file (or directory) specified in the object path.

 

Properties

The Win32_Directory class has these properties.

AccessMask
Data type: uint32
Access type: Read-only

Bitmask that represents the access rights required to access or perform specific operations on the directory. For bit values, see File and Directory Access Rights Constants.

Note  On FAT volumes, the FULL_ACCESS value is returned instead, which indicates no security has been set on the object.

ValueMeaning
FILE_READ_DATA (file), FILE_LIST_DIRECTORY (directory)
0 (0x0)

Grants the right to read data from the file. For a directory, this value grants the right to list the contents of the directory.

FILE_WRITE_DATA (file), FILE_ADD_FILE (directory)
1 (0x1)

Grants the right to write data to the file. For a directory, this value grants the right to create a file in the directory.

FILE_APPEND_DATA (file), FILE_ADD_SUBDIRECTORY
4 (0x4)

Grants the right to append data to the file. For a directory, this value grants the right to create a subdirectory.

FILE_READ_EA
8 (0x8)

Grants the right to read extended attributes.

FILE_WRITE_EA
16 (0x10)

Grants the right to write extended attributes.

FILE_EXECUTE (file), FILE_TRAVERSE (directory)
32 (0x20)

Grants the right to execute a file. For a directory, the directory can be traversed.

FILE_DELETE_CHILD
64 (0x40)

Grants the right to delete a directory and all of the files it contains (its children), even if the files are read-only.

FILE_READ_ATTRIBUTES
128 (0x80)

Grants the right to read file attributes.

FILE_WRITE_ATTRIBUTES
256 (0x100)

Grants the right to change file attributes.

DELETE
65536 (0x10000)

Grants delete access.

READ_CONTROL
131072 (0x20000)

Grants read access to the security descriptor and owner.

WRITE_DAC
262144 (0x40000)

Grants write access to the discretionary ACL.

WRITE_OWNER
524288 (0x80000)

Assigns the write owner.

SYNCHRONIZE
1048576 (0x100000)

Synchronizes access and allows a process to wait for an object to enter the signaled state.

ACCESS_SYSTEM_SECURITY
18809343 (0x11F01FF)

Controls the ability to get or set the SACL in an object's security descriptor.

 

Archive
Data type: boolean
Access type: Read-only

Indicates whether the archive bit on the folder has been set. The archive bit is used by backup programs to identify files that should be backed up. If True, the file should be archived.

Caption
Data type: string
Access type: Read-only

Short description of the object. This property is inherited from CIM_ManagedSystemElement.

Compressed
Data type: boolean
Access type: Read-only

Indicates whether or not the folder has been compressed. WMI recognizes folders compressed using WMI itself or using the graphical user interface; it does not, however, recognize .ZIP files as being compressed. If True, the file is compressed.

CompressionMethod
Data type: string
Access type: Read-only

Algorithm or tool (usually a method) used to compress the logical file. If it is not possible (or not desired) to describe the compression scheme (perhaps because it is not known), use the following words: "Unknown" to represent that it is not known whether the logical file is compressed; "Compressed" to represent that the file is compressed, but either its compression scheme is not known or not disclosed; and "Not Compressed" to represent that the logical file is not compressed.

CreationClassName
Data type: string
Access type: Read-only

Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, this property allows all instances of this class and its subclasses to be uniquely identified.

CreationDate
Data type: datetime
Access type: Read-only

Date that the file system object was created. For more information on working with WMI date and time formats, see WMI Tasks: Dates and Times.

CSCreationClassName
Data type: string
Access type: Read-only

Creation class name of the scoping computer system.

CSName
Data type: string
Access type: Read-only

Name of the computer where the file system object is stored.

Description
Data type: string
Access type: Read-only

Description of the object. This property is inherited from CIM_ManagedSystemElement.

Drive
Data type: string
Access type: Read-only

Drive letter of the drive (including colon) where the file system object is stored.

Example: "c:"

EightDotThreeFileName
Data type: string
Access type: Read-only

MS-DOS®-compatible name for the folder.

Example: "c:\progra~1"

Encrypted
Data type: boolean
Access type: Read-only

Indicates whether or not the folder has been encrypted. If True, the folder is encrypted.

EncryptionMethod
Data type: string
Access type: Read-only

Algorithm or tool used to encrypt the logical file. If it is not possible (or not desired) to describe the encryption scheme (perhaps for security reasons), use the following words: "Unknown" to represent that it is not known whether the logical file is encrypted; "Encrypted" to represent that the file is encrypted, but either its encryption scheme is not known or not disclosed; and "Not Encrypted" to represent that the logical file is not encrypted.

Extension
Data type: string
Access type: Read-only

File name extension for the file system object, not including the dot (.) that separates the extension from the file name.

Examples: "txt", "mof", "mdb"

FileName
Data type: string
Access type: Read-only

File name (without the dot or extension) of the file.

Example: "autoexec"

FileSize
Data type: uint64
Access type: Read-only

Size of the file system object, in bytes. Although folders possess a FileSize property, the value 0 is always returned. To determine the size of a folder, use the FileSystemObject or add up the size of all the files stored in the folder.

For more information about using uint64 values in scripts, see Scripting in WMI.

FileType
Data type: string
Access type: Read-only

File type (indicated by the Extension property).

For example, an .mdb file is likely to have the file type Microsoft Access Application. An .asp file likely has the file type HTML Document. Folders are typically reported simply as Folder.

FSCreationClassName
Data type: string
Access type: Read-only

Class of the file system.

FSName
Data type: string
Access type: Read-only

Type of file system (NTFS, FAT, FAT32) installed on the drive where the file or folder is located.

Hidden
Data type: boolean
Access type: Read-only

Indicates whether the file system object is hidden. If True, the file is hidden.

InstallDate
Data type: datetime
Access type: Read-only

The date the object was installed. This property does not require a value to indicate that the object is installed. This property is inherited from CIM_ManagedSystemElement. For more information on working with WMI date and time formats, see WMI Tasks: Dates and Times.

InUseCount
Data type: uint64
Access type: Read-only

Number of "file opens" that are currently active against the file.

For more information about using uint64 values in scripts, see Scripting in WMI.

LastAccessed
Data type: datetime
Access type: Read-only

Date the file was last accessed. For more information on working with WMI date and time formats, see WMI Tasks: Dates and Times.

LastModified
Data type: datetime
Access type: Read-only

Date the file was last modified. For more information on working with WMI date and time formats, see WMI Tasks: Dates and Times.

Name
Data type: string
Access type: Read-only

Inherited name that serves as a key of a logical file instance within a file system. Full path names should be provided. This property is inherited from CIM_ManagedSystemElement.

Example: "c:\winnt\system\win.ini"

Path
Data type: string
Access type: Read-only

Path for the file. The path includes the leading and trailing backslashes, but not the drive letter or the folder name.

For the folder c:\windows\system32\wbem, the path is \windows\system32\. For the folder c:\scripts, the path is \.

Readable
Data type: boolean
Access type: Read-only

Indicates whether you can read items in the folder. If True, the file can be read.

Status
Data type: string
Access type: Read-only
Qualifiers: MaxLen (10)

Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states. This property is inherited from CIM_ManagedSystemElement.

The values are:

"OK"
"Error"
"Degraded"
"Unknown"
"Pred Fail"
"Starting"
"Stopping"
"Service"
"Stressed"
"NonRecover"
"No Contact"
"Lost Comm"
System
Data type: boolean
Access type: Read-only

Indicates whether the object is a system file. If True, the file is a system file

Writeable
Data type: boolean
Access type: Read-only

If True, the file can be written.

Remarks

The Win32_Directory class is derived from CIM_Directory.

Overview

Folders are file system objects designed to contain other file system objects. This does not mean that all folders are alike, however. Instead, folders can vary considerably. Some folders are operating system folders, which generally should not be modified by a script. Some folders are read-only, which means that users can access the contents of that folder but cannot add to, delete from, or modify those contents. Some folders are compressed for optimal storage, while others are hidden and not visible to users.

WMI uses the Win32_Directory class to manage folders. Significantly, the properties and methods available in this class are identical to the properties and methods available in the CIM_DataFile class, the class used to manage files. This means that after you have learned how to manage folders using WMI, you will, without any extra work, also know how to manage files.

The Win32_Subdirectory association class is also used to manage files and folders. The Win32_Subdirectory class relates a folder and its immediate subfolders. For example, in the folder structure C:\Scripts\Logs, Logs is a subfolder of Scripts, and Scripts is a subfolder of the root folder C:\. However, Logs is not considered a subfolder of C:\.

You can retrieve the properties of any folder in the file system using the Win32_Directory class. The properties available using this class are shown in Table 11.1. To retrieve the properties for a single folder, construct a Windows Query Language (WQL) query for the Win32_Directory class, making sure that you include the name of the folder. For example, this query binds to the folder D:\Archive:

Copy "SELECT * FROM Win32_Directory WHERE Name = 'D:\\Archive'"

When specifying a file or folder name in a WQL query, be sure you use two backslashes (\\) to separate path components.

If you want to limit data retrieval to a single disk drive, include a Where clause specifying the drive letter. For example, this query returns a list of all the folders on drive C:

"SELECT * FROM Win32_Directory WHERE Drive = 'C:'"

If you need to enumerate all the folders on a computer, be aware that this query can take an extended time to complete.

Examples

The following VBScript sample retrieves properties for the folder C:\Scripts.


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_Directory WHERE Name = 'c:\\Scripts'")
For Each objFolder in colFolders
 Wscript.Echo "Archive: " & objFolder.Archive
 Wscript.Echo "Caption: " & objFolder.Caption
 Wscript.Echo "Compressed: " & objFolder.Compressed
 Wscript.Echo "Compression method: " & objFolder.CompressionMethod
 Wscript.Echo "Creation date: " & objFolder.CreationDate
 Wscript.Echo "Encrypted: " & objFolder.Encrypted
 Wscript.Echo "Encryption method: " & objFolder.EncryptionMethod
 Wscript.Echo "Hidden: " & objFolder.Hidden
 Wscript.Echo "In use count: " & objFolder.InUseCount
 Wscript.Echo "Last accessed: " & objFolder.LastAccessed
 Wscript.Echo "Last modified: " & objFolder.LastModified
 Wscript.Echo "Name: " & objFolder.Name
 Wscript.Echo "Path: " & objFolder.Path
 Wscript.Echo "Readable: " & objFolder.Readable
 Wscript.Echo "System: " & objFolder.System
 Wscript.Echo "Writeable: " & objFolder.Writeable
Next

The following VBScript sample returns a list of all the hidden folders on a computer.


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_Directory WHERE Hidden = True")
For Each objFile in colFiles
 Wscript.Echo objFile.Name
Next

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

CIMWin32.mof

DLL

CIMWin32.dll

See also

Operating System Classes

 

 

Show:
© 2014 Microsoft