OK, I’ll make this easy…
if a user creates a profile folder from a 2000 login on a 2000 filserver, the permisions are set so only they can access the folder, we as domain admins don’t even have access.
I’m trying to make a ‘user deleter’ in VBS I’ve got most of it working, to some degree. to delete the profiles folder you need to take ownership and then alter the acl to allow access, so then it can be deleted, BUT it never allows me to take ownership of the ‘my documents’ folder, I can go in and do it manualy but not programaticaly.
This is some of the code I have come up with, feel free to pick it full of holes, and before anyone says I know there a more than lickly tools we could use to do this but we are not allowed to use them.
StrUser = "A1234567"
strProfileLetter = "U"
Call TakeOwnership2(StrProfileLetter,StrUser,"")
Call TakeOwnership2(StrProfileLetter,StrUser, "\My Documents")
wscript.quit
Sub TakeOwnership2(vardrive,varpath,VarExtra)
strOwnerFolder = chr(34) & vardrive & ":\\" & varpath & "\" & VarExtra & chr(34)
cmdline = "Select * From Win32_Directory Where Name = " & StrOwnerFolder
Set colFolders = objWMIService.ExecQuery (cmdline)
For Each objFolder In colFolders
msgbox objFolder.name
objFolder.TakeOwnershipEx,True
Next
runme = "%COMSPEC% /c Echo Y| cacls " & Vardrive & ":\" & VarPath & varextra & " /t /e /c /g " & chr(34) & "Domain Admins" & chr(34) & ":f " & chr(34) & "system" & chr(34) & ":f /R " & chr(34) & "Everyone" & chr(34)
intRunError = WSHShell.Run(runme, 2, True)
msgbox "Changing ACL - " & intrunerror
If intRunError <> 0 Then
strmsg = "Failed changing ACL"
Else
StrMsg = "completed"
End If
intRunError2 = WSHShell.Run("cmd /c attrib -R -S " & VarDrive & ":\" & VarPAth & varextra & "\*.* /S", 0, VBTrue)
msgbox "Changing Attrib - " & intrunerror2
If intRunError2 <> 0 Then
strmsg = "Failed Changing Attrib"
Else
StrMsg = "completed"
End If
End Sub