Link to home
Start Free TrialLog in
Avatar of Sudoku_Warriors
Sudoku_Warriors

asked on

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

            
Avatar of sirbounty
sirbounty
Flag of United States of America image

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

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

Avatar of Sudoku_Warriors
Sudoku_Warriors

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Awesome thanks very much...I really appreciate it.