?
Solved

Combining 3 individual scripts into 1

Posted on 2008-11-10
5
Medium Priority
?
164 Views
Last Modified: 2012-05-05
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

            
0
Comment
Question by:Sudoku_Warriors
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22931299
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 22931344
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
 
LVL 1

Author Comment

by:Sudoku_Warriors
ID: 22936580
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
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 22938678
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
 
LVL 1

Author Closing Comment

by:Sudoku_Warriors
ID: 31516235
Awesome thanks very much...I really appreciate it.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question