Problems with Win32_Directory Delete method

  • Thread starter Thread starter Brian MXP
  • Start date Start date
B

Brian MXP

Hello-

I'm aware of the post-SP2 changes for the Win32_Directory (or Win32_Subdirectory) Delete
methods (where you can't delete a directory if a subdirectory exists), but still can't
seem to successfully do what I want - which is delete user profiles from remote machines
using WMI & VBScript.

But even when I copy/paste the code in:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0405.mspx

and run it against a strFolderName like "c:\documents and settings\joeuser", I usually end
up with a (null): 0x80041017 error in the line reading:

For Each objFolder in colSubfolders (or For Each objFolder2 in colSubFolders2)

and the colSubFolders is set to:

Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")


Has anyone found success in using this newer method (enumerating the entire folder tree &
then deleting them from the bottom up)? Or found any problems/better ways to do it?

Thanks,
Brian
 
Brian MXP said:
Hello-

I'm aware of the post-SP2 changes for the Win32_Directory (or Win32_Subdirectory) Delete
methods (where you can't delete a directory if a subdirectory exists), but still can't
seem to successfully do what I want - which is delete user profiles from remote machines
using WMI & VBScript.

But even when I copy/paste the code in:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0405.mspx

and run it against a strFolderName like "c:\documents and settings\joeuser", I usually end
up with a (null): 0x80041017 error in the line reading:

For Each objFolder in colSubfolders (or For Each objFolder2 in colSubFolders2)

and the colSubFolders is set to:

Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")


Has anyone found success in using this newer method (enumerating the entire folder tree &
then deleting them from the bottom up)? Or found any problems/better ways to do it?

Thanks,
Brian
 
Back
Top