Script for setting staff permissions

Ok, that last script was kind of complex.  This one is a lot simpler.  It is the script we use to set permissions on staff users.  Occasionally the permissions have a way of getting out of whack, as accounts are created and modified over time.  Running this script will reset the permissions to all users in a particular folder.  It requires the callcacls.bat and caclscmd.bat scripts from the last post.  You will need to modify the Path variable on line 30, as well as the ScriptPath on line 14.  Change the names of the possible InputType values on Line 21 to match the names of the folders that end the path containing your user folders.  For Instance, as written, the script will allow you to set permissions on all user folders in \\FileServerPath\CO-USERS or \\FileServerPath\ELEM-USERS or \\FileServerPath\HS-USERS or \\FileServerPath\JH-USERS
Add or remove destinations as needed.
 
—Begin StaffPermissions.vbs—
‘ Created by – Jay Morgan
‘ Bowling Green City Schools
jay.morgan@bgreen.kyschools.us
Option Explicit
dim ScriptPath
dim InputType             ‘string variable input by user – tells us whether it is a single student or entire grade
dim InputSure             ‘string variable input by user – user confirmation prompt response
dim Path                  ‘string variable manipulated by script – Path to modify folder ACLs in
dim Cancel                ‘boolean variable manipulated by script – to identify whether Cancel was clicked in InputBox, or blank field submitted
dim Result                ‘placeholder variable for running ModifyACL function
ScriptPath = "\\server\share\folder\callcacls.bat"
InputType = "z"
InputSure = "N"
Cancel = false
If Cancel = False then
 while ucase(InputType) <> "CO-USERS" and ucase(InputType) <> "ELEM-USERS" and ucase(InputType) <> "HS-USERS" and ucase(InputType) <> "JH-USERS" and InputType <> ""
  InputType = inputbox("Enter the name of the share (i.e. CO-Users)")
  InputType = ucase(InputType)
  If InputType = "" Then
   Cancel = True
  End If
 wend
End If
If Cancel = False then
 Path = "\\FileServerPath\" & InputType & "\*.*"
 while Cancel = False
  InputSure = inputbox("Modify All user ACLs FOR " & InputType & " – Are you sure? (y/n):","Modify ACLs", "Y")
  If InputSure = "" then
   Cancel = True
  elseif ucase(InputSure) = "Y" then
   Result = ModifyACL(Path)
   msgbox("Operation complete – Modified share permissions")
   Cancel = True
  elseif ucase(InputSure) = "N" then
   msgbox("Aborting")
   Cancel = True
  end if
 wend
End If    ‘If Cancel = False
Function ModifyACL(ModPath)
 Dim WshShell
 dim Cmd
 dim BtnCode
 set WshShell = CreateObject("Wscript.Shell")
 Cmd = ScriptPath & " " & ModPath
wscript.echo Cmd
 WshShell.Run Cmd
 BtnCode = WshShell.popup(Cmd, 600)
 MOdifyACL = ModPath
End Function
—End StaffPermissions.vbs—
Advertisements

~ by Jay P Morgan on July 21, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s