Shared Folders

You can use the Shared Folders Microsoft Management Console (MMC) snap-in to centrally manage file shares on a computer. Shared Folders enables you to create file shares and set permissions, as well as view and manage open files and users connected to file shares on the computer.

  • Share a Folder or Drive

  • Stop Sharing a Folder or Drive

  • Close an Open File

  • Disconnect a User

  • Set Permissions for Shared Folders

  • Configure Offline Availability for a Shared Folder

  • Limit the Number of Users of a Shared Folder

  • Understanding Shared Folders and the Windows Firewall

  • Troubleshooting Shared Folders


Share a Folder or Drive

There are several methods you can use to share folders and files with others on the network. The Create a Shared Folder Wizard guides you through the steps of setting up a basic shared folder. You can also use the command-line interface to share a folder or drive.

Share a folder or drive

  • Using the Windows interface

  • Using a command line

To share a folder or a drive by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Shares.

  4. On the Action menu, click New Share.

  5. Follow the steps in the Create a Shared Folder Wizard, and then click Finish.

To share a folder or a drive by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type:

    net share <sharename=drive:path>

    For example, to share a folder named myshare located on drive C, in the path \Users\Myname, type:

    net share myshare=C:\Users\Myname

Value | Description
Net share | Creates, deletes, or displays shared folders.
<sharename> | The network name of the shared folder.
<drive:path> | The absolute path of the shared folder.
Note

To view the complete syntax for this command, at the command prompt, type: net help share

Additional references

Command-line syntax notation


Stop Sharing a Folder or Drive

You can stop sharing a folder or drive by using the Shared Folders Microsoft Management Console (MMC) snap-in or by using a command prompt.

Important

Users connected to a shared folder are disconnected when you stop sharing it. Users may lose data if you stop sharing a folder containing an open shared file without warning. When possible, notify users before you stop sharing a folder.

Stop sharing a folder or drive

  • Using the Windows interface

  • Using a command line

To stop sharing a folder by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, then click Shared Folders, and then click Shares.

  4. In the details pane, right-click a shared folder, and then click Stop Sharing.

    To stop sharing multiple files, press the CTRL key while clicking the file names, right-click any one of the selected files, and then click Stop Sharing. This removes shared network access to the selected files.

To stop sharing a folder by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type:

    net share <sharename> /delete.

    For example, to stop sharing a folder called myshare, type:

    net share myshare /delete

Value | Description
Net share | Creates, deletes, or displays shared folders.
<sharename> | The network name of the shared folder.
/delete | Stops sharing the folder.
Note

To view the complete syntax for this command, at the command prompt, type: net help share

Additional references


Close an Open File

You can close shared files or folders by using the Shared Folders Microsoft Management Console (MMC) snap-in or by using a command prompt.

Important

Users connected to a shared file or folder are disconnected when you close it. Users may lose data if you close an open shared file without warning. When possible notify users before closing files and disconnecting them.

Closing an open file

  • Using the Windows interface

  • Using a command line

To close an open shared file or folder by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Open Files.

  4. Do one of the following:

    • To close all open files and folders, on the Action menu, click Disconnect All Open Files.

    • To close a specific file or folder, in the Results pane right-click the file or folder name, and then click Close Open File.

    • To disconnect multiple open files or folders, press the CTRL key while clicking the file or folder names, right-click any one of the selected files or folders, and then click Close Open File. This closes the selected files or folders.

To close an open shared file or folder by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type:

    net file <ID> /close

    For example, to close an open file identified as myfile_id, type:

    net file myfile_id /close

Value | Description
Net file | Displays the names of all open shared files or folders on a server and the number of file locks, if any, on each file or folder.
<ID> | The dynamically assigned ID of the shared file or folder.
/close | Closes the shared file or folder and removes file locks. Type this command from the server where the folder is shared.
Notes
  • To view the complete syntax for this command, at the command prompt, type: net help file
  • To see the file ID of the shared file or folder, type net file

Additional references


Disconnect a User

You can disconnect users from a shared folder by using the Shared Folders MMC snap-in or by using the command prompt. You cannot disconnect users through Windows Explorer.

Important

Users may lose data if disconnected without warning. When possible, notify users before disconnecting them.

Disconnect a user or users

  • Using the Windows interface

  • Using a command line

To disconnect a user or all users from a shared folder or drive by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Sessions.

  4. To disconnect all users, on the Action menu, click Disconnect all users. To disconnect a specific user, in the Details pane right-click the user name, and then click Close Session.

To disconnect a user or all users from a shared folder or drive by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type:

    net session \\<computer> /delete

    For example, to disconnect a user on a computer named user_computer, which is connected to a shared folder that you are managing, type:

    net session \\user_computer /delete

Value | Description
Net session | Lists or disconnects users connected to shared folders on the computer.
\\<computer> | The name of the computer accessing the shared folder.
/delete | Ends the session, and closes all open files on the computer for the session. If you omit \\computer, the command ends the sessions on the local computer.
Note

To view the complete syntax for this command, at the command prompt, type: net help session

Additional references


Set Permissions for Shared Folders

Share permissions apply to users who connect to a shared folder over the network. Share permissions do not affect users who log on locally, or log on using Remote Desktop.

To set permissions for users who log on locally or using Remote Desktop, use the options on the Security tab instead of the Share Permissions tab. This sets permissions at the NTFS file system level. If both share permissions and file system permissions are set for a shared folder, the more restrictive permissions apply when connecting to the shared folder.

For example, to give Read access on a shared folder to users in your domain, on the Share Permissions tab, set permissions for the Everyone group to Full Control. On the Security tab, specify more restrictive access by setting the permissions for the Domain Users group to Read access. The result is that a user who is a member of the Domain Users group has read-only access to the shared folder whether the user is connected through a network share, through Remote Desktop, or is logged on locally.

You can set file system level permissions at the command line by using the operating system tool iCacls.exe or Cacls.exe. The tools run only on an NTFS volume.

Note

To enable access-based enumeration on a shared folder, you must use Share and Storage Management. Access-based enumeration allows users to see only the files and folders in a shared folder to which they have permission to access. For more information, see http://go.microsoft.com/fwlink/?LinkId=141539.

Set permissions on shared folders

  • Using the Windows interface

  • Using a command line

To set permissions on a shared folder by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Shares.

  4. In the details pane, right-click the shared folder, and then click Properties.

  5. On the Share Permissions tab, set the permissions you want:

    • To assign permissions to a shared folder to a user or group, click Add. In the Select Users, Computers, or Groups dialog box, find or type the user or group name, and then click OK.

    • To revoke access to the shared folder, click Remove.

    • To set individual permissions for the user or group, in Permissions for group or user, select Allow or Deny.

  6. To set file and folder permissions that apply to users who log on locally or using Remote Desktop Services, click the Security tab and set the appropriate permissions.

To specify file permissions for a user by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. To set individual permissions for a user or group, type:

    cacls /G <user:permission>

    For example, to specify Write permissions for a user with the user name Monica on a file named 002.jpg, type:

    cacls 002.jpg /G Monica:w

  4. To revoke access to the shared folder, type:

    cacls /R <user>

    For example, to revoke access to the shared folder for a user with user name Monica, type:

    Cacls /R Monica

Value Description

cacls

Displays or modifies access control lists (ACL) of files.

/R

Revokes the specified user's access rights

/G

Grants access rights to the specified user

<user>

The user or group whose access rights are being set.

<permission>

The permission being granted to the user. This can be one of the following:

  • N (None)

  • W (Write)

  • C (Change)

  • F (Full control)

Additional references


Configure Offline Availability for a Shared Folder

The caching feature of Shared Folders ensures that users have access to shared files even when they are working offline without access to the network. You can also use Shared Folders or Share and Storage Management to enable BranchCache on shared resources. The BranchCache feature in Windows® 7 or Windows Server 2008 R2 enables computers in a branch office to cache files downloaded from this shared folder, and then securely serve the files to other computers in the branch.

You can also configure Offline Files and BranchCache by using Group Policy. For a complete list of Group Policy settings, see the Microsoft Web site (http://go.microsoft.com/fwlink/?LinkId=142412).

Important

When you create a shared folder, offline availability is enabled by default, which means that secure folders can be stored offline on potentially non secure computers. For increased security, do not allow users to store files offline. If you do, consider encrypting the operating system volume using Windows® BitLocker™ Drive Encryption. For more information, see the BitLocker Drive Encryption page of the Microsoft Web site (http://go.microsoft.com/fwlink/?LinkId=141534).

Set caching options for a shared folder

  • Using the Windows interface

  • Using a command line

To set caching options for a shared folder by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Shares.

  4. In the results pane, right-click the shared folder, and then click Properties.

  5. On the General tab, click Offline Settings, configure the offline availability options as appropriate and then click OK.

Offline availability options

You can select one of the following offline availability options for each shared folder:

  • Only the files and programs that users specify are available offline. This is the default option when you set up a shared folder. By using this option, no files or programs are available offline by default, and users control which files and programs they want to access when they are not connected to the network.

    • Enable BranchCache Enables computers in a branch office to cache files downloaded from this shared folder and then securely serve the files to other computers in the branch office. To enable BranchCache, you must first install the BranchCache for network files role service by using Server Manager.

  • No files or programs from the share are available offline. This option blocks Offline Files on the client computers from making copies of the files and programs on the shared folder.

  • All files and programs that users open from the share are automatically available offline. Whenever a user accesses the shared folder or volume and opens a file or program in it, that file or program will be automatically made available offline to that user. Files and programs that are automatically made available offline will remain in the Offline Files cache and synchronize with the version on the server until the cache is full or the user deletes the files. Files and programs that are not opened are not available offline.

    If you select the Optimized for performance check box, executable files (EXE, DLL) that are run from the shared folder by a client computer are automatically cached on that client computer. The next time the client computer runs the executable files, it will access its local cache instead of the shared folder on the server.

    Note

    The Offline Files feature must be enabled on the client computer for files and programs to be automatically cached. Additionally, the Optimized for performance option does not have any effect on client computers using Windows Vista or newer.

To set caching options for a shared folder by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type one of the following commands to specify caching for this shared folder:

    net share <sharename> /cache:manual
net share <sharename> /cache:BranchCache
net share <sharename> /cache:documents
net share <sharename> /cache:programs
net share <sharename> /cache:none

    For example, to allows users to identify the documents and programs they want to store offline from the shared folder named myshare, type:

    net share myshare /cache:manual

Value | Description
Net share | Manages shared folders.
<sharename> | The name of the shared folder.
/cache:manual | Allows users to identify the documents and programs they want to store offline. Corresponds to the following option in the Windows interface: Only the files and programs that users specify are available offline.
/cache:BranchCache | Enables BranchCache and manual caching of documents on the shared folder. Corresponds to the following options in the Windows interface: Enable BranchCache and Only the files and programs that users specify are available offline.
/cache:documents | Automatically stores documents offline. Corresponds to the following option in the Windows interface: All files and programs that users open from the share are automatically available offline.
/cache:programs | Automatically stores documents and programs offline. Corresponds to the following option in the Windows interface: Optimized for performance.
/cache:none | Prevents users from storing documents and programs offline. Corresponds to the following option in the Windows interface: No files or programs from the share are available offline.
Notes
  • To view the complete syntax for this command, at the command prompt, type: net help share
  • To display information about a shared folder, type: net share <sharename>

Additional references

  • BranchCache Deployment Guide

  • Command-line syntax notation


Limit the Number of Users of a Shared Folder

You can share folders and files with others on your network or you can share your entire hard disk. For more control, you can specify the number of users you allow to simultaneously connect to the shared folder.

The maximum number of users allowed to connect to a shared folder is limited by software licensing terms.

Limit the number of users of a shared folder

  • Using the Windows interface

  • Using a command line

To limit the number of users of a shared folder by using the Windows interface

  1. Open Computer Management.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. In the console tree, click System Tools, click Shared Folders, and then click Shares.

  4. In the details pane, right-click the shared folder, and then click Properties.

  5. On the General tab, under User limit, specify the limit you want:

    • To set the limit at the maximum number, click Maximum allowed.

    • To specify a number for the limit, click Allow this number of users, and then type the number of users in the box.

To limit the number of users of a shared folder by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

  3. Type:

    net share <sharename> /users:<number>

    For example, to specify a limit of three users who can simultaneously connect to your shared folder named myshare, type:

    net share myshare /users:3

Value | Description
Net share | Creates, deletes, or displays shared folder.
<Sharename> | The network name of the shared folder.
/users:<number> | Sets the maximum number of users who can simultaneously access the shared folder.
Note

To view the complete syntax for this command, at the command prompt, type: net help share

Additional references


Understanding Shared Folders and the Windows Firewall

Sharing a folder or file creates a Windows Firewall exception for File and Printer Sharing. The exception opens the ports listed in the following table.

Connection | Ports
TCP | 139, 445
UDP | 137, 138

The default scope is to allow access from any computer on the network, including computers on the Internet. Unless you block incoming connections on these ports using a hardware firewall, firewall server, or other Internet-sharing device, your computer will be vulnerable to attack from the Internet as long as your Internet connection is active.

For more information about Windows Firewall, click Start, click Help and Support, and then search for the keyword Firewall.


Troubleshooting Shared Folders

What problem are you having?

  • I cannot access shared folders

  • I cannot view shared folder information in Shared Folders

  • I cannot view a folder in a shared folder on which Access-based enumeration is enabled
I cannot access shared folders.
  • Cause: The network connection was lost.

  • Solution: Verify network settings. Check your connection to other resources on the network, such as internal Web sites.

  • Cause: Share permissions or file system permissions prevent access.

  • Solution: Verify that the share permissions and file system permissions on the computer to which you are connecting allow you or your group access to the shared folder.

    If you can access Shared Folders on the remote computer, check the Sessions folder to determine the user rights with which you are logged on to the remote computer.

    Check the Share Permissions that are set for the Everyone group. If there is a check mark in the Deny column, no one will be able to access the shared folder, even if Full Control permissions are granted to the Administrators group. Remove the check mark and grant Full Control to appropriate users and groups.

I cannot view shared folder information in Shared Folders.
  • Cause: You are not logged on to the specified computer as a member of the Administrators group, Server Operators group, or a group that has the appropriate user rights.

  • Solution: Ensure that you are a member of a group (such as the Administrators group) with the appropriate user rights before connecting to the shared folder.

I cannot view a folder in a shared folder on which access-based enumeration is enabled.
  • Cause: The user does not have the Read permission to the folder in a shared folder on which access-based enumeration is enabled, or the Special permissions have been modified. Access-based enumeration hides folders or other shared resources that the user does not have rights to access.

  • Solution: Check that the user has Read permission on the appropriate folder, and that the user has the following Special permissions in the Advanced Security Settings dialog box:

    • List folder / read data

    • Read attributes

    • Read extended attributes

    • Read permissions

    For more information about access-based enumeration, see http://go.microsoft.com/fwlink/?LinkId=141539.


Command-line syntax notation

The following table describes the notation used to indicate command-line syntax.

Notation | Description
Text without brackets or braces | Items you must type as shown
<Text inside angle brackets> | Placeholder for which you must supply a value
[Text inside square brackets] | Optional items
{Text inside braces} | Set of required items; choose one
Vertical bar (|) | Separator for mutually exclusive items; choose one
Ellipsis (…) | Items that can be repeated