Using NET SHARE to Configure Windows Server 2008 R2 File Sharing

From Techotopia
Jump to: navigation, search
PreviousTable of ContentsNext
Configuring Windows Server 2008 R2 File SharingUnderstanding Windows Server 2008 R2 File and Folder Ownership and Permissions


<google>BUY_WINSERV_2008R2</google>

The preceding chapter entitled Configuring Windows Server 2008 R2 File Sharing focused on the creation of file shares in Windows Server 2008 R2 using graphical tools. Often it is quicker and more efficient for the experienced system administrator to configure shares by entering a few quick net share commands at the command prompt. As such, this topic will be covered in detail in this chapter.


Contents


Net Share Command-line Syntax

The first step in learning to use the net share command is to gain a basic understanding of the command line syntax of the tool. In basic terms, the syntax for net share is as follows:

NET SHARE
sharename
          sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
                               [/USERS:number | /UNLIMITED]
                               [/REMARK:"text"]
                               [/CACHE:Manual | Documents| Programs | None ]
          sharename [/USERS:number | /UNLIMITED]
                    [/REMARK:"text"]
                    [/CACHE:Manual | Documents | Programs | None]
          {sharename | devicename | drive:path} /DELETE
          sharename \\computername /DELETE

As illustrated above, many of the tasks which can be performed using the graphical tools can also be performed using the command line. In the remainder of this chapter, some of the more common sharing tasks using net share will be covered.

Note that to perform any tasks other than viewing the current shares, the command-prompt must be running with administrator privileges. This can be achieved by right clicking on the Command Prompt in the Start menu and selecting Run as administrator.

Getting Share Information using Net Share

To obtain information about currently configured shares on a Windows Server 2008 R2 system simply execute the net share command will no command-line options:

C:\Windows\system32>net share

Share name   Resource                        Remark

-----------------------------------------------------------------------------
C$           C:\                             Default share
E$           E:\                             Default share
IPC$                                         Remote IPC
ADMIN$       C:\Windows                      Remote Admin
MyFolder     C:\Users\bill\MyFolder
Users        C:\Users

The command completed successfully.

Creating a Share using Net Share

Perhaps the most common requirement when working with shared files and folders is to create a new share. The most basic of commands simply creates the share and assigns a share name. For example:

C:\Windows\system32>net share MyFolder=c:\users\bill\MyFolder
MyFolder was shared successfully.

In the above example, the folder located at c:\users\bill\MyFolder has been shared using the share name MyFolder. By default, Windows will assign read permission to Everyone when a share is created without specifying any permissions.

In order to grant specific permissions to individual users or groups, the /GRANT option must be used when creating the share to specify the share permissions to be assigned. For example, the following command creates the MyFolder share assigning full permission to user fred:

 
C:\Windows\system32>net share MyFolder=c:\users\bill\MyFolder /GRANT:fred,FULL
MyFolder was shared successfully.

If permissions need to be granted to multiple users or groups, the /GRANT option may be used multiple times in a single net share command. In the following example, full share permissions are granted to user fred while bill is only assigned read permission:

 
C:\Windows\system32>net share MyFolder /DELETE
MyFolder was deleted successfully.

Using Net Share to Delete a Share from a Remote Server

The net share command may also be used to delete a share from a remote server. In order to achieve this, the name of the remote computer on which the share resides must be specified before the /DELETE option prefixed with \\. In the following command-line, the share named MyFolder is removed from a remote server named winserver-2:

C:\Windows\system32>net share MyFolder \\winserver-2 /DELETE
MyFolder was deleted successfully.

Once executed, the above command will delete the share named MyFolder from the remote server named winserver-2 such that it is no longer available for remote shared access.

<google>BUY_WINSERV_2008R2_BOTTOM</google>