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_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.

Syntax

[Provider("CIMWin32")]class Win32_Share : CIM_LogicalElement
{
  uint32   AccessMask;
  boolean  AllowMaximum;
  string   Caption;
  string   Description;
  datetime InstallDate;
  uint32   MaximumAllowed;
  string   Name;
  string   Path;
  string   Status;
  uint32   Type;
};

Members

The Win32_Share class has these types of members:

Methods

The Win32_Share class has these methods.

MethodDescription
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.

 

Properties

The Win32_Share class has these properties.

AccessMask
Data type: uint32
Access type: Read-only

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

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

Short description of the object.

Description
Data type: string
Access type: Read-only

Description of the object.

InstallDate
Data type: datetime
Access type: Read-only

Object was installed. This property does not need a value to indicate that the object is installed.

MaximumAllowed
Data type: uint32
Access type: Read-only

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

Alias given to a path set up as a share on a computer system running Windows.

Windows 2003 example: "public"

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

Local path of the Windows share.

Example: "C:\Program Files"

Status
Data type: string
Access type: Read-only

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.

The values are:

"OK"
"Error"
"Degraded"
"Unknown"
"Pred Fail"
"Starting"
"Stopping"
"Service"
"Stressed"
"Nonrecover"
"NoContact"
"LostComm"
Type
Data type: uint32
Access type: Read-only

Type of resource being shared. Types include: disk drives, print queues, interprocess communications (IPC), and general devices.

ValueMeaning
0 (0x0)

Disk Drive

1 (0x1)

Print Queue

2 (0x2)

Device

3 (0x3)

IPC

2147483648 (0x80000000)

Disk Drive Admin

2147483649 (0x80000001)

Print Queue Admin

2147483650 (0x80000002)

Device Admin

2147483651 (0x80000003)

IPC Admin

 

Remarks

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.

Examples

The following Script Centercode example lists all shares on a computer, and list all the share permissions for each share.

The Get Share Information similar to Win32_Share PowerShell sample queries Win32_Share and provides the results.

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

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
WMI Tasks: Files and Folders

 

 

Show:
© 2014 Microsoft