Using NET SHARE to Configure Windows Server 2008 File Sharing

Follow Techotopia on Twitter Bookmark and Share

From Techotopia

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


Purchase and download the fully updated Windows Server 2008 R2 edition of this eBook in PDF and ePub formats for only $9.99  Add to Cart


The preceding chapter, entitled Configuring Windows Server 2008 File Sharing focused on the creation of file shares in Windows Server 2008 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




[edit] 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.

[edit] Getting Share Information using Net Share

To obtain information about currently configured shares on a Windows Server 2008 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.

[edit] 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=c:\users\bill\MyFolder /GRANT:fred,FULL 
/GRANT:bill,READ
MyFolder was shared successfully.

To create a share with comments use the /REMARK argument following by the comment text:

C:\Windows\system32>net share MyFolder=c:\users\nas\MyFolder /REMARK:"My SharedFolder"
MyFolder was shared successfully.

[edit] Using Net Share to Delete a Share from a Local Server

To remove a share from a local server using the net share command together the share name of the share to be deleted together with the /DELETE option. For example:

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

[edit] 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.

Purchase and download the complete, updated Windows Server 2008 R2 edition
of this eBook in PDF and ePub formats for only $9.99

Add to Cart

Views
Personal tools

Find us on Facebook