Creating a share and granting permissions via cmd.exe and net share

Jesper Lund Stocholm picture Jesper Lund Stocholm · Aug 15, 2014 · Viewed 16.2k times · Source

I am trying to create a share on a Windows Server 2008.

I can do it fine via the GUI and everything works like a charm.

But when I try to do it via the command prompt (I need the command prompt for a FinalBuilder WMI action step), nothing happens.

I use the command:

C:\>net share MyShare=d:\MyShareFolder /grant:Everyone,FULL

It returns a message like "Share was created", and it is indeed created - but the permissions are not applied.

I originally tried to grant a specific user to the share, but this also fails. The command was this:

C:\>net share MyShare=d:\MyShareFolder /grant:domain\myuser,FULL

I also tried to use double-quotes around the domain\user-specification, but same result.

There must be something that I am missing - but what is it?

Thanks,

/Jesper

Answer

Griner picture Griner · May 26, 2015

You have to make sure that the user have permissions granted to the folder.

Ex.:

icacls "d:\MyShareFolder" /grant myuser:(OI)(CI)F