Using NET SHARE to Configure Windows Server 2008 File Sharing
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.
The first step in learning to use the net share command is to gian 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 command sharing tasks using net share will be covered.
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.
Perhaps the most 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.