Combining 3 individual scripts into 1

Hi,

I have absolutely no idea on scripting so im really sorry for this post.

All i want to do is create a folder on a share and give it specific permissions. When I run the script manually either in a .bat file or whatever is easiest  I want it to prompt me for a specific username and after i enter the username I pusk enter and it goes away and creates the folder and sorts out the specific permissions on the share...I have been given the following scripts which im told will do this individually. So how can i combine them? I just want to enter the username name in once...Thanks very very much

Script to make folders

md \\filesrv1\email\USERNAME| md \\filesrv1\email\USERNAME\outlook| md \\filesrv1\email\USERNAME\notes

 Script to set permissions on top level folder to Domain Admins and System only

echo y|cacls \\filesrv1\email\USERNAME /S:"D:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;DA)"

 Script to add change permissions for user to each folder

cacls "\\filesrv1\email\USERNAME\notes" /G "TENNIS\USERNAME":C /E|cacls "\\filesrv1\email\USERNAME\outlook" /G "TENNIS\USERNAME":C /E|cacls "\\filesrv1\email\USERNAME" /G "TENNIS\USERNAME":C /E

            
LVL 1
Sudoku_WarriorsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
This should do it...
@echo off
set /a strUser = Enter username:
 
if not exist \\filesrv1\email\%strUser% md \\filesrv1\email\%strUser%
if not exist \\filesrv1\email\%strUser%\outlook md \\filesrv1\email\%strUser%\outlook
if not exist \\filesrv1\email\%strUser%\notes md \\filesrv1\email\%strUser%\notes
 
echo y|cacls \\filesrv1\email\%strUser% /S:"D:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;DA)"
 
cacls "\\filesrv1\email\%strUser%\notes" /G "TENNIS\%strUser%":C /E|cacls "\\filesrv1\email\%strUser%\outlook" /G "TENNIS\%strUser%":C /E|cacls "\\filesrv1\email\%strUser%" /G "TENNIS\%strUser%":C /E

Open in new window

0
sirbountyCommented:
This version allows for a little more control - you can just update the server/path if those values ever change by correcting the first two set statements on line 2 & 3.
@echo off
Set strServer=\\filesrv1
Set strServerPath=%strServer%\email
 
set /a strUser = Enter username:
 
Set UserMailFolder=%strServerPath%\%strUser%
 
if not exist %UserMailFolder% md %UserMailFolder%
for %%a in (outlook notes) do if not exist %UserMailFolder%\%%a md %UserMailFolder%\%%a
 
echo y|cacls %UserMailFolder% /S:"D:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;DA)"
 
cacls "%UserMailFolder%\notes" /G "TENNIS\%strUser%":C /E|cacls "%UserMailFolder%\outlook" /G "TENNIS\%strUser%":C /E|cacls "%UserMailFolder%" /G "TENNIS\%strUser%":C /E

Open in new window

0
Sudoku_WarriorsAuthor Commented:
Hi,

Thanks for getting back to me promptly...

I created a batch file and pasted the code in..Ran the batch file as an administrator.

It didnt prompt me for a username however it did run and it created a folder called O. Within that folder were two other folders called Outlook and Notes which was supposed to happen..The permissions looked correct appart from the fact that their was no user permissions..when I added a pause and ran it again a message appears saying "missing operator"

Thanks for your help...
foldercreate-script.doc
0
sirbountyCommented:
my mistake, it should be set /p, not set /a...



@echo off
Set strServer=\\filesrv1
Set strServerPath=%strServer%\email
 
set /p strUser=Enter username:
 
Set UserMailFolder=%strServerPath%\%strUser%
 
if not exist %UserMailFolder% md %UserMailFolder%
for %%a in (outlook notes) do if not exist %UserMailFolder%\%%a md %UserMailFolder%\%%a
 
echo y|cacls %UserMailFolder% /S:"D:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;DA)"
 
cacls "%UserMailFolder%\notes" /G "TENNIS\%strUser%":C /E|cacls "%UserMailFolder%\outlook" /G "TENNIS\%strUser%":C /E|cacls "%UserMailFolder%" /G "TENNIS\%strUser%":C /E

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sudoku_WarriorsAuthor Commented:
Awesome thanks very much...I really appreciate it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

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.