We can use net share command to create, configure and delete network shares from command line . Below you can find syntax and examples for net share command.

Create a network share from command line

The syntax for creating a share is as follows.

net share sharename=folderpath /grant:username,permissions

sharename: You can assign name to the share you are going to create
username : Login id of the user whom you want to share the folder with
permission: Read, Change or Full

For example to share the folder E:\Docs with everyone in the domain and to give full permissions

net share Docs=E:\Documents /grant:everyone,FULL

If you are allowing multiple users to access the share, you can limit the number of users accessing the share simultaneously. This will prevent performance impact on your system. The below command will set the limit to 10 users.

net share Docs=E:\Documents /grant:everyone,FULL  /users:10

Command to share with a specific user and to grant only read rights:

net share Docs=E:\Documents /grant:username,READ

Delete network share(i.e to disable sharing of the folder) from command line

net share sharename /delete

For example, to delete the share created above, the command would be as below.

net share docs /delete

Alternatively, we can use the folder physical location also to disable sharing

 net share E:\Docs /delete

List the shared created on the local computer

net share

Delete the share on a remote computer

net share sharename \\remotepc /delete

Di paolo