|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Share Out All Folders In A Folder
Hello,
I am migrating a server that holds all the home folder for users to another folder. I robocopied the folders to the new folder but the sharing does not copy. I am trying to write a script to share the folder and share it as hidden. I know the syntax is "net share username$=d:\Users\username /unlimited". I need to loop it for all the folders in a certain folder. Also each share name has to be the name of the folder with the $ to hide it. Any suggestions would be appreciated. Thanks in advance. <cro***@gmail.com> wrote in message
Show quote news:1192809020.928213.168700@q5g2000prf.googlegroups.com... run this as a batch script in a .cmd file:> Hello, > > I am migrating a server that holds all the home folder for users to > another folder. I robocopied the folders to the new folder but the > sharing does not copy. I am trying to write a script to share the > folder and share it as hidden. I know the syntax is "net share > username$=d:\Users\username /unlimited". I need to loop it for all > the folders in a certain folder. Also each share name has to be the > name of the folder with the $ to hide it. Any suggestions would be > appreciated. > > Thanks in advance. > @echo off setlocal enabledelayedexpansion (set/p _root=Enter path of folder containing user folders: ) for /d %%F in ("%_root%\*") do ( (set _sn=%%~nF) echo/net share !_sn!$="%%~F" /unlimited ) When you are comfortable that the echo commands are showing net share commands that do what you want, edit out the "echo/" and run again. Note that this does no error checking, and problems will arise if any folder names contain spaces. What we used to do in such migrations was to save the share definitions from the registry, edit them if required, and import them into the registry on the new server. Not much fun, so now we don't bother sharing the users home folders in favour of defining them with a UNC like: \\servername\usershares$\user1 instead of a share like: \\servername\user1$ This has no adverse effects unless you have win9x clients. By the way, this was a bit trickier than I expected, because the most obvious approach would be: for /d %%F in ("%_root%\*") do ( echo/net share %%~nF$="%%~F" /unlimited ) For some reason that escapes me at present, this results in net share commands like this: net share %~nF$="C:\test this\user1" /unlimited net share %~nF$="C:\test this\user2" /unlimited anyone care to clue me in on this? /Al |
|||||||||||||||||||||||