Win32_Share class
The Win32_Share class represents a shared resource on a computer system running Windows. This may be a disk drive, printer, interprocess communication, or other sharable device. For more information about retrieving WMI classes, see Retrieving a Class.
The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties and methods are in alphabetic order, not MOF order.
[Dynamic, Provider("CIMWin32"), UUID("{8502C4D6-5FBB-11D2-AAC1-006008C78BC7}"), SupportsCreate, CreateBy("Create"), SupportsDelete, DeleteBy("DeleteInstance"), AMENDMENT]
class Win32_Share : CIM_LogicalElement
{
string Caption;
string Description;
datetime InstallDate;
string Status;
uint32 AccessMask;
boolean AllowMaximum;
uint32 MaximumAllowed;
string Name;
string Path;
uint32 Type;
};
The Win32_Share class has these types of members:
The Win32_Share class has these methods.
Method | Description |
---|---|
Create | Class method that initiates sharing for a server resource. |
Delete | Class method that deletes a share name from a server's list of shared resources, disconnecting connections to the shared resource. |
GetAccessMask | Returns the access rights to the share held by the user or group on whose behalf the instance is returned. You should use this method in place of the AccessMask property, which is always NULL. |
SetShareInfo | Class method that sets the parameters of a shared resource. |
The Win32_Share class has these properties.
-
AccessMask
-
-
Data type: uint32
-
Access type: Read-only
-
Qualifiers: DEPRECATED
This property is obsolete and is no longer used. Use the Win32_Share.GetAccessMask method instead. The value of the AccessMask property is set to null by WMI. For more information about setting access when a share is created, see the Create method.
-
-
AllowMaximum
-
-
Data type: boolean
-
Access type: Read-only
-
Qualifiers: MappingStrings ("Win32API|Network Management Structures|SHARE_INFO_502|shi502_max_uses")
Number of concurrent users for this resource has been limited. If True, the value in the MaximumAllowed property is ignored.
-
-
Caption
-
-
Data type: string
-
Access type: Read-only
-
Qualifiers: MaxLen (64), DisplayName ("Caption")
A short textual description of the object.
This property is inherited from CIM_ManagedSystemElement.
-
-
Description
-
-
Data type: string
-
Access type: Read-only
-
Qualifiers: DisplayName ("Description")
A textual description of the object.
This property is inherited from CIM_ManagedSystemElement.
-
-
InstallDate
-
-
Data type: datetime
-
Access type: Read-only
-
Qualifiers: MappingStrings ("MIF.DMTF|ComponentID|001.5"), DisplayName ("Install Date")
Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.
This property is inherited from CIM_ManagedSystemElement.
-
-
MaximumAllowed
-
-
Data type: uint32
-
Access type: Read-only
-
Qualifiers: MappingStrings ("Win32API|Network Management Structures|SHARE_INFO_502|shi502_max_uses")
Limit on the maximum number of users allowed to use this resource concurrently. The value is only valid if the AllowMaximum property is set to FALSE.
-
-
Name
-
-
Data type: string
-
Access type: Read-only
-
Qualifiers: key, Override ("Name"), MappingStrings ("Win32API|Network Management Structures|SHARE_INFO_1|shi1_netname")
Alias given to a path set up as a share on a computer system running Windows.
Windows 2008 example: "\SERVER01\public" - Windows Server 2008 requires that you place the UNC in the name.
-
-
Path
-
-
Data type: string
-
Access type: Read-only
-
Qualifiers: MappingStrings ("Win32API|Network Management Structures|SHARE_INFO_502|shi502_path")
Local path of the Windows share.
Example: "C:\Program Files"
-
-
Status
-
-
Data type: string
-
Access type: Read-only
-
Qualifiers: MaxLen (10), DisplayName ("Status")
String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive).
Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states.
This property is inherited from CIM_ManagedSystemElement.
Values include the following:
-
-
OK ("OK")
-
Error ("Error")
-
Degraded ("Degraded")
-
Unknown ("Unknown")
-
Pred Fail ("Pred Fail")
-
Starting ("Starting")
-
Stopping ("Stopping")
-
Service ("Service")
-
Stressed ("Stressed")
-
NonRecover ("NonRecover")
-
No Contact ("No Contact")
-
Lost Comm ("Lost Comm")
Type
-
Data type: uint32
-
Access type: Read-only
-
Qualifiers: MappingStrings ("Win32API|Network Management Structures|SHARE_INFO_502|shi502_type")
Type of resource being shared. Types include: disk drives, print queues, interprocess communications (IPC), and general devices.
Disk Drive (0)
Print Queue (1)
Device (2)
IPC (3)
Disk Drive Admin (2147483648)
Print Queue Admin (2147483649)
Device Admin (2147483650)
IPC Admin (2147483651)
The Win32_Share class is derived from CIM_LogicalElement.
The Create method in this class is a static method. The Delete, GetAccessMask and SetShareInfo methods are all instance methods.
Depending on your security permissions, you may not be able to retrieve all of the properties of this class. For example, AllowMaximum, MaximumAllowed, Path, and Type properties may return null. Generally speaking, Power Users and Administrators will be able to retrieve all property values.
The following PowerShell sample displays the shares on the local system.
$shares = Get-WMIObject -class Win32_share
"Shares on : {0}" -f $((gwmi win32_computersystem).name)
$shares | sort name | ft -auto
Alternately, if you wish to filter more precisely, you can use the following PowerShell snippet:
gwmi -q "SELECT * FROM Win32_Share WHERE Name != 'ADMIN$' AND Name != 'IPC$'"
The Following VBScript sample displays the shares on the local system.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Share")
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Caption: " & objItem.Caption & "=" & objItem.Path
Next
Requirement | Value |
---|---|
Minimum supported client |
Windows Vista |
Minimum supported server |
Windows Server 2008 |
Namespace |
Root\CIMV2 |
MOF |
|
DLL |
|