Changes

Jump to: navigation, search
Net Share Command-line Syntax
== Net Share Command-line Syntax ==
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: <pre>NET SHAREsharename 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</pre> 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. == 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: <pre>C:\Windows\system32>net share Share name Resource Remark -----------------------------------------------------------------------------C$ C:\ Default shareE$ E:\ Default shareIPC$ Remote IPCADMIN$ C:\Windows Remote AdminMyFolder C:\Users\bill\MyFolderUsers C:\UsersThe command completed successfully.</pre> == Creating a Sahre using Net Share == 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: <pre>C:\Windows\system32>net share MyFolder=c:\users\bill\MyFolderMyFolder was shared successfully.</pre> 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: <pre>C:\Windows\system32>net share MyFolder=c:\users\bill\MyFolder /GRANT:fred,FULLMyFolder was shared successfully.</pre> 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: <pre>C:\Windows\system32>net share MyFolder=c:\users\bill\MyFolder /GRANT:fred,FULL /GRANT:bill,READMyFolder was shared successfully.</pre>

Navigation menu