Suppresion de dossier - VB/VBA/VBS - Programmation
MarshPosté le 03-05-2005 à 11:59:57
Set objFSO = CreateObject("Scripting.FileSystemObject" ) Set objFolder = objFSO.GetFolder("\\Mgdn0954\c$\Documents and Settings\" ) Set colSubfolders = objFolder.Subfolders For Each objSubfolder in colSubfolders ' Wscript.Echo objSubfolder.Name, objSubfolder.Size if (objSubfolder.Name<>"Administrateur" ) then if (objSubfolder.Name<>"All Users" ) then if (objSubfolder.Name<>"LocalService" ) then if (objSubfolder.Name<>"NetworkService" ) then if (objSubfolder.Name<>"Default User" ) then Wscript.Echo objSubfolder.Name strComputer = "MGDN0954" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2" ) Set colFolders = objWMIService.ExecQuery _ ("Select * from Win32_Directory where Name = 'C:\\Documents and Settings\\"&objSubfolder.Name&"'" ) For Each objFolder in colFolders errResults = objFolder.Delete Wscript.Echo objSubfolder.Name&" "&errResults Next end if end if end if end if end if Next Wscript.Echo "pwet"
Bonjour,
J'ai fait ce script pour supprimer des dossiers mais quand je le lance il me met des erreurs 14.
Quelle est cette erreur, et comment y remedier ???
Marsh Posté le 03-05-2005 à 11:59:57
Set objFSO = CreateObject("Scripting.FileSystemObject" )
Set objFolder = objFSO.GetFolder("\\Mgdn0954\c$\Documents and Settings\" )
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
' Wscript.Echo objSubfolder.Name, objSubfolder.Size
if (objSubfolder.Name<>"Administrateur" ) then
if (objSubfolder.Name<>"All Users" ) then
if (objSubfolder.Name<>"LocalService" ) then
if (objSubfolder.Name<>"NetworkService" ) then
if (objSubfolder.Name<>"Default User" ) then
Wscript.Echo objSubfolder.Name
strComputer = "MGDN0954"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2" )
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = 'C:\\Documents and Settings\\"&objSubfolder.Name&"'" )
For Each objFolder in colFolders
errResults = objFolder.Delete
Wscript.Echo objSubfolder.Name&" "&errResults
Next
end if
end if
end if
end if
end if
Next
Wscript.Echo "pwet"
Bonjour,
J'ai fait ce script pour supprimer des dossiers mais quand je le lance il me met des erreurs 14.
Quelle est cette erreur, et comment y remedier ???