Help me! It's driving me nuts

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

Well I would think Delete of My Doc’s folder would be better clear items first, have you tried that first?

I finally got it sorted this afternoon, my code was screwed, I was using the command wrong, sorted now but left the code at work.

Like to post the revised code?

At a guess…was it strOwnerFolder = chr(34) & vardrive & “:\” & varpath & “[B][/B]” & VarExtra & chr(34) clashing with “[B][/B]My Documents”?

nah it wasn’t that bit nightlord, it was actualy the bit with the takeownershipex bit, I can’t remember exactly what I changed but when I get the code (I’ll have someone mail me it on monday) I’ll post it up.