Managing shares at the command line

Posted On 2010-02-27 by dwirch
Tags: Tutorial Tip Windows Server 2008 Windows 7
Views: 11242

Manage your shares from the command prompt with built-in-to-Windows tools, and leave the GUI to the noobs.

There are many ways to manage shares using the graphical interface of Windows Explorer. There are some of us die-hard command prompt junkies that prefer working at the text level, however. Also, in some cases, you may only have a command prompt for your admin duties.

Windows Server 2008 includes a variation of installation called Server Core. Server Core is a significantly scaled-back installation where no Windows Explorer shell is installed. All configuration and maintenance is done entirely through command line interface windows, or by connecting to the machine remotely using Microsoft Management Console. However, Notepad and some control panel applets, such as Regional Settings, are available.

So onward, to share management.

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. Let's take a look at the help file for NET SHARE, which we will be using to manage our shares.

sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
[/USERS:number | /UNLIMITED]
[/CACHE:Manual | Documents| Programs | None ]
sharename [/USERS:number | /UNLIMITED]
[/CACHE:Manual | Documents | Programs | None]
{sharename | devicename | drive:path} /DELETE
sharename \\computername /DELETE

As you can see by this list, many of the tasks you would normally use the GUI for, you can also perform with the command line tool. In this article, we'll just cover some of the highlights:

  • View current shares
  • Create a share
  • Manager Share Permissions
  • Delete a share

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.

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:\>net share

Share name Resource Remark

ADMIN$ C:\Windows Remote Admin
C$ C:\ Default share
print$ C:\Windows\system32\spool\drivers
Printer Drivers
K$ K:\ Default share
IPC$ Remote IPC
TestFolder c:\test
Users C:\Users
The command completed successfully.

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:\>net share TestFolder=c:\test
TestFolder was shared successfully.

In the above example, the folder located at c:\test has been shared using the share name TestFolder. 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 TestFolder share assigning full permission to user George:

C:\>net share TestFolder=c:\test /GRANT:George,FULL
TestFolder 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 George while Steve is only assigned read permission:

C:\>net share TestFolder=c:\test /GRANT:George,FULL /GRANT:Steve,READ
TestFolder was shared successfully.

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

C:\>net share TestFolder=c:\test /REMARK:"The Test Folder"
TestFolder was shared successfully.

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:\>net share TestFolder /DELETEM
TestFolder was deleted successfully.

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 TestFolder is removed from a remote server named winserver-2:

C:\>net share TestFolder \\MyServer /DELETE
TestFolder was deleted successfully.

Once executed, provided you have administrative permissions on the remote computer, the above command will delete the share named TestFolder from the remote server named MyServer such that it is no longer available for remote shared access.

About the Author

dwirch has posted a total of 179 articles.

You can find more information from dwirch by visiting

Comments On This Post

By: AnonymousCoward
Date: 2015-08-08

Ok, everything worked fine, but when I try to grant full acces to a specific user in my local network it gave the 1332 error. 
i tried this: "net share toshi=e:\sharedfolder /grant:gonzalo-unzueta\gonzalo,full" where gonzalo-unzueta is another computer in local network and gonzalo a user of that computer. 

By: dwirch
Date: 2015-08-08

If the computers are in workgroup mode, I believe you can only use local accounts; you won't be able to reference accounts maintained on other computers in the network. 

If you want to reference accounts that are not local to the machine share is on, you need to set up a domain, and utilize domain accounts.

By: gonchi_Bolivia
Date: 2015-08-13

Oh hehe, didn't know that it would appear my name as AnonymousCoward =P 

But thank you for the answere. You are right my computers are in workgroup mode, was kind of annoying not knowing why I couldn't do that, now that I know, I'll set up a Domain. 

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers