net share

You are currently browsing articles tagged net share.

I had to lately migrate some hidden shares from one server to another.
I wanted to use “File Server Migration Wizard”, but could not, as Windows 2008 R2 Standard edition will not let you do it, because you do not run enterprise or data-center edition. I got a little annoyed about this and quickly googled for solution. I found the solution described below here posted by Doug_H.

First thing, copy your folders, just use ROBOCOPY to do it for you and it will copy your security attributes too, like in example below:

SET _source="\\server01\d$\Users"
SET _dest="D:\Users"
SET _options=/R:0 /W:0 /LOG:C:\temp\Users_log.txt /NFL /NDL
ROBOCOPY %_source% %_dest% %_what% %_options%

Then we share the folders. My share names are the same as folders names, and hidden $.
So first you populate a file with the folder names, use cmd:

 DIR /A:D /B > c:\temp\dir_list.txt 

and then you query thru the file and use net share to share your folders with permissions you want like in example below:

 for /F %%X in (c:\temp\dir_list.txt) do (net share %%X$=d:\Users\%%X /GRANT:AdminGroup,FULL /GRANT:%%X,CHANGE) 

The command above has to be run in .bat file, so you need to create one, for example: sharefolders.bat and have the command entered in there, then you run it.

And we are done. Pretty simple, obvious and useful, so sharing.

Locations of visitors to this page