cacks and vbscript

cacks and vbscript

Post by Jeremy Sch » Tue, 17 Jul 2007 00:15:24


'm creating a HTA that assists teachers to create folders on student
machines and to set NTFS permissions so that only specific students may
access each folder. (Students are rendering movies in these folderrs). I
modified the following line I found on the web. Can someone please tell me
what the 2 and true at the end are for?

intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g ""Domain Admins"":F SYSTEM:F CSSDSTU\GG047-CTSMOVIE:F", 2, True)

Also, I paste my cacls section below. Although it looks long, there are
really only 3 sections.
1. Grant full permissions to those who need it and remove the everyone
group. This section runs no matter what.
2. Grant modify permissions for up to four users chosen by the teachers
3. Revoke permissions to the folder for up to four students selected by
the teachers
What I've pasted below seems the most logical way to me to go abot this.
But I'm open to any other suggestions...

Thanks, Jeremy


CODE
----------------
'GRANT PERMISSIONS FOR ALL ~ADMINISTRATIVE~ GROUPS TO THE CREATED FOLDER
'Script always runs through this section
'Use cacls to edit existing permissions to grant full permissions to:
administrators,system, and cssdstu\gg047-ctsmovie
'The first line is error checking to confirm the existance of folder
If objFSO.FolderExists(strDirectory) Then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g ""Domain Admins"":F SYSTEM:F CSSDSTU\GG047-CTSMOVIE:F", 2, True)
Msgbox "The system account and local administrators have been granted
full control to this folder." & VbCrLf "CTS teachers have also _
been granted full control to this folder"
'Use cacls to remove permissions for the EVERYONE group
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /r " & "EVERYONE", 2, True)
Else
Msgbox "The folder " & strDirectoryName & " does not exist. Please try
again"
'Go to the start over flag
End If

'GRANT MODIFY PERMISSIONS FOR UP TO FOUR CTS STUDENTS (AT A TIME)
'This section only runs if the option to grant one or more users permissions
is checked off
'Use cacls to grant modify permissons to user1, and or user2 and or user3
and or user4
If GRANT1.Checked Then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g " & USER1.VALUE & ":c", 2, True)
If intRunError <> 0 Then
Msgbox "An error has occured. Make sure that user " & USER1.VALUE & "
exists."
Else
Msgbox USER1.VALUE & " has been granted modify permissions to the folder."
End If
End If
If GRANT2.Checked then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g " & USER2.VALUE & ":c", 2, True)
If intRunError <> 0 Then
Msgbox "An error has occured. Make sure that user " & USER2.VALUE & "
exists."
Else
Msgbox USER2.VALUE & " has been granted modify permissions to the folder."
End If
End If
If GRANT3.Checked then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g " & USER3.VALUE & ":c", 2, True)
If intRunError <> 0 Then
Msgbox "An error has occured. Make sure that user " & USER3.VALUE & "
exists."
Else
Msgbox USER3.VALUE & " has been granted modify permissions to the folder."
End If
End If
If GRANT4.Checked then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory &
" /e /g " &
 
 
 

cacks and vbscript

Post by Richard Mu » Tue, 17 Jul 2007 01:14:14

he Run method of the wshShell object takes 3 parameters, the last 2
optional. The first is the command to run. The second indicates how the app
should run, 2 means to run minimized. If the third parameter is True it
means to wait for the command to finish before continuing, which is
necessary if the command it to return a value (the value of intRunError).

See the WSH documentation for more:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"Jeremy Schubert" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...