The Computer Oracle

Create network shares via command line with specific permissions

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open

--

Chapters
00:00 Create Network Shares Via Command Line With Specific Permissions
00:45 Accepted Answer Score 5
01:12 Answer 2 Score 11
01:42 Thank you

--

Full question
https://superuser.com/questions/419611/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#commandline #networkshares #windowsserver2003

#avk47



ANSWER 1

Score 11


The command you're looking for is net share. The /? help on the command is pretty straightforward, but here is an example:

net share MyShareName="C:\My Local Path\SomeFolder" /GRANT:Everyone,FULL

As far as security goes, from what I've read, the best-practice is to do as above, grant the Everyone group full control on the share, and then manage the permissions on the files and folders themselves. This is because the share permissions are a restriction filter over top of the actual file and folder permissions.




ACCEPTED ANSWER

Score 5


This should be the information that you are looking for:

::Create a drive letter map to an existing network share
net use z: \\servername\share password /USER:domain\username /PERSISTENT:YES

:: grant user 'jsmith' full control access to the jsmith directory
cacls z:\jsmith /T /E /G jsmith:f

You can also remove permissions, or edit permissions on the directory using cacls.exe. My recommendation would be to read up on cacls.exe

Cacls

http://technet.microsoft.com/en-us/library/bb490872.aspx

or just "cacls /?" from the command line should work as well.