Create shared folders with Command Line

Create shared folders with Command Line

Working with multiple users and computers connected in a network at home or at work, ultimately involves sharing files one way or another.

To keep control, create or automate the mapping, the net share command is the right tool in Windows.

But make sure the Network Discovery and Folder and Printer Sharing are turned ON. And confirm that the services for DNS Client, Function Discovery Resource Publication, SSDP Discovery and UPnP Device Host are running.

net share

Shows the list of mappable and mapped folders.

net share Name=”Path” /grant:Username,Permission

Name: Meaningful name
Path: Folder path with drive letter ex: C:\Drivers
Username: User ID to be granted with permission or Everyone for anyone
Permission: Change, Read, or Full

Note: the grant command can be repeated per each user in the same expression

net share Name=”Path” /grant:Username,Permission /users:5

The same as the one before but with the possibility of limiting the amount of users. Change the number 5 to the quantity you need, or unlimited for any amount.

net share Name /delete

Replace Name with the share share name to be deleted.

To audit who has access to the folder and manage it another command is used, but its out the scope of this post.