Create a folder and set permissions from a txt file.

Hi,

Create a folder and set permissions from a txt file.
I have the uer names in a txt file. Need to create the folder name as the user name and set everyone full access in the share and set the user name as Full access in the security permissions.
No one else just that user should be in there.

Windows 2003 server i need to create these folders.

REgards
Sharath'
LVL 11
bsharathAsked:
Who is Participating?
 
AmazingTechCommented:
Yes. It has been awhile. I've been mainly in MSDOS and Windows Batch Scripting. Not too much in vbscript. Trying to save my time doing other things.

Your son must be getting big.

Modify your sharefolder.

Set ShareFolder=C:
Set ShareFolder=C:
Set Domain=YourDomain
for /f %%a in (Users.txt) do call :process "%%a"
goto :eof
 
:process
set folder=%~1
set fullpath=%ShareFolder%\%Folder%
md "%fullpath%"
net share %folder%="%fullpath%" /grant:Everyone,Full
echo y|cacls "%fullpath%" /t /g %domain%\%folder%:F %domain%\Administrator:F SYSTEM:F
pause 

Open in new window

0
 
AmazingTechCommented:
Give this a try.
Set ShareFolder=D:\TestFolder
Set Domain=YourDomain
for /f %%a in (Users.txt) do call :process "%%a"
goto :eof
 
:process
set folder=%~1
set fullpath=%ShareFolder%\%Folder%
md "%fullpath%"
net share %folder%="%fullpath%" /grant:Everyone,Full
echo y|cacls "%fullpath%" /t /g %domain%\%folder%:F %domain%\Administrator:F SYSTEM:F
pause

Open in new window

0
 
bsharathAuthor Commented:
Hi AT how are you...Long time no see... :-))

I get this

C:\>Set ShareFolder=c:\

C:\>Set Domain=Development

C:\>for /F %a in (Users.txt) do call :process "%a"

C:\>call :process "sharath"

C:\>set folder=sharath

C:\>set fullpath=c:\\sharath

C:\>md "c:\\sharath"

C:\>net share sharath="c:\\sharath" /grant:Everyone,Full
System error 123 has occurred.

The filename, directory name, or volume label syntax is incorrect.


C:\>echo y  | cacls "c:\\sharath" /t /g Development\sharath:F Development\Admi
nistrator:F SYSTEM:F
Are you sure (Y/N)?processed dir: c:\sharath

C:\>pause
Press any key to continue . . .

I have the cacls in the same folder too
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
bsharathAuthor Commented:
Thanks AT

Ya my Son is doing really fine.. He has been growing tooo fast.

:-)

Please take time to have a view at my posts when time permists... :-)
0
 
bsharathAuthor Commented:
Thanks AT

Ya my Son is doing really fine.. He has been growing tooo fast.

:-)

Please take time to have a view at my posts when time permists... :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.