How To Add, Remove and Manage Windows Shares Network Drives From Command Line? – POFTUT

How To Add, Remove and Manage Windows Shares Network Drives From Command Line?

Windows operating systems provides some mechanism to share the resources between different systems. One of the most known and popular tool to manage these resources is net command whit related sub command. In this tutorial we will look how to create, mount, remove and manage network shares with net use  and net share command.


We will use following syntax for net use.


Help about net use command can be get with the following command.

net use Help

net use Help

Create Share

We will create a share which maps to the C:\cygwin64 folder.  We will also set the network share name as myshare with the following command. We will provide the share name and the path like below.

net use - Create Share

net use – Create Share

We have successfully created the share named myshare . If we have do not have permission for given mapped shared directory we will get error and the share will not created.

List Shares

Existing shares can be listed with net share command without providing any parameter. This will list current host network shares.

List Shares with net use

List Shares with net use

As we see from screenshot there are a lot of shares. Shares like C$, ADMIN$ are created by default. If we do not need them we should remove them. Listing shares provides following information

  • Share name is the name used to mount this share in the client side
  • Resource is the path the share will be mapped
  •  Remark is comments  and notes about this share which is set while share creation.
LEARN MORE  What is SMB Port and Port Number? Which Protocol Uses Port 445 and Port 139 ?

Mount Share

We have created and listed shares in previous mount shares are easy as creating them. We will use net use command to mount a windows share from command line. We will mount share named myshare located at to our drive z: .

echo '

Mount Share with net use

Mount Share with net use

We have successfully mounted the share. While mounting user credentials should be provided. but in this example the share was created with the same user who mounts the share. So we have all ready have permission access to the share.

List Mounted Shares

We have mounted the remote file share in the previous example. We can list all ready mounted shares simply using net use command like below.

List Mounted Shares with net use

List Mounted Shares with net use

Listing shares will provide information like below.

  • Status shows current situation like connected or not connected
  • Local shown the local mount point
  • Remote shows remote file share full path including the host name/IP address and the path
  • Network shows network used to access share.

Unmount Share

We can unmount a share similar like mounting it. We will provide /delete option to the mount command like below. In the example we will unmount the remote share name  \\\myshare from our local system.

Delete or Remove Share With Share Name

We can stop sharing previously shared resource with the /delete parameter and the share name. In this example we will stop sharing myshare .

LEARN MORE  How To Install OwnCloud On CentOS Linux?

Delete or Remove Share

Delete or Remove Share

Delete or Remove Share With Physical Location

Alternative way to remove a share is providing the physical location of the shares. This will delete related share and share name. In this example we will provide physical location as c:\cygwin64 to remove related share.

Delete or Remove Share From Remote Computer

In previous example we have removed existing share from local computer. We can also remove remote systems share by specifying remote system IP address or host name. In this example we will remove share from with the following command.

Set Permission For Share Access

While creating network shares the access permission is important factor for security reasons. We must set which users accounts can access to the share with which access rights. This can be set with /GRANT option and specifying user and rights. Syntax of grant options is like below.

In this  example we will give user account john full access which means READ , WRITE and EXECUTE permissions for the given share.

1 Response

  1. Kamal says:

    Thank you very much for this explanation. It easy to folow. Great job

Leave a Reply

Your email address will not be published. Required fields are marked *