batch file to share folders in windows 7
What would be the easiest way to run a batch / script file in Windows 7 to share 30 folders, each to a different user? They must write their backups over the network to this one PC standing separately with a huge HDD on which there is 30 folders.
Each person has his/her own folder to which he/she must get full access, but nobody else. Apologies but I'm new to Wi开发者_JS百科n7 and scripting.
Powershell? It must e.g. create the share John$, on the folder C:\John, with permissions = person John only, who has userid XYZ12345 on our network. And then for the other 29 people too, each with their own folder name and user id.
Trust me, I really did try to browse around but I'm getting more and more confused.
Much appreciated.
net share <share name>=<drive>:<dir> /grant:<user>,FULL /remark="description"
Will create the share with full permissions for - for more detailed permissions you might have to use setacl.exe
So the individual pieces you need from the command line are:
- A way to iterate through users' names
- A way to create a directory
- A command to share a folder with a particular permission set
You should be able to do that with a plain old batch script. Looping through a list of names is easy, depending on how you want to specify the names. You could do something like:
FOR /F "tokens=*" %%G IN ("John Mary Matt Greg") DO ...
Where "..." is a subroutine to create the folder and share. That's where net share
comes in. For each user you can do something like:
MKDIR %1
NET SHARE %1=%1 /GRANT:%1
精彩评论