Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: problem deleting folders with WMI

HTVi
TV Discussion Newsgroups

problem deleting folders with WMI
Brian MXP <brian[ at ]nospam.broad.mit.edu> 6/12/2007 2:14:30 PM
Howdy-

I'm aware of the post-XP 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.

Even if 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
RE: problem deleting folders with WMI
Blackhawk 6/25/2007 5:36:01 PM
I discoverd that Win32_Directory problem with subfolders where folder names
are GUIDs. Script would just fail. Had to rewrite a script from a nice
central/enterprise idea to a locally run FileSystemObject based one. Sigh...
--
....Blackhawk, always learning something new.


"Brian MXP" wrote:

[Quoted Text]
> Howdy-
>
> I'm aware of the post-XP 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.
>
> Even if 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
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen