Tuesday, July 29, 2008

Create shares script

Automate the sharing of all folders in the current directory as hidden shares ($) with the share permissions of "Domain Admins" Full Control and the "user account associated with the folder" Change (Assuming the folder is named the same as the user name).

Copy the following into notepad and save as Create Shares.cmd:

@echo off
TITLE Creating shares
DIR /A:D /B >Folderlist.txt
FOR /F %%1 IN (Folderlist.txt) DO NET SHARE "%%1$" = "current local path\%%1" /GRANT: "Domain Admins",FULL /GRANT:"%%1",CHANGE
PAUSE