How can I create a shared folder from the Windows command line?
Asked Answered
F

2

25

As far as I'm aware, this is done via the net command.

However, the help section isn't very helpful, as it only shows me the secondary options and not how to use those.

Suppose I had a folder C:\Share_test

How would I make it shared from the command line?

Fruma answered 8/10, 2009 at 10:55 Comment(0)
E
31

C:\> net help share

For example:

To share a computer's C:\Data directory with the share name DataShare and include a remark, type:

net share DataShare=c:\Data /remark:"For department 123."

Elsey answered 8/10, 2009 at 10:59 Comment(1)
Some additional information as in the other answer and using the exact sample from the question would be betterNonprofit
C
34

Using the "net help share" command you will see that the syntax is as follows:

net share sharename=drive:path

For example, if I had a folder S:\Public which I wanted to share as "Public" the command would be:

net share Public=s:\Public

The above command will automatically grant "Everyone" with Read permissions only. If you want to grant Everyone with Full Control the command would be:

net share Public=s:\Public /GRANT:Everyone,FULL

Keep in mind that NTFS permissions still apply, so even though you might have granted EVERYONE with FULL access to the share, you'll still have to check the NTFS security permissions to ensure that the right people have permission there too.

Christensen answered 4/3, 2014 at 7:16 Comment(1)
A side note about localisation: spanish user should write /GRANT:Todos,FULL . Change it accordingly to your language.Younker
E
31

C:\> net help share

For example:

To share a computer's C:\Data directory with the share name DataShare and include a remark, type:

net share DataShare=c:\Data /remark:"For department 123."

Elsey answered 8/10, 2009 at 10:59 Comment(1)
Some additional information as in the other answer and using the exact sample from the question would be betterNonprofit

© 2022 - 2024 — McMap. All rights reserved.