cmd vbscript delete subdirectories & files with error level
Path = Wscript.Arguments(0)
on error resume next
error = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.GetFolder(Path)
wscript.echo "delete Files and Folders in " & Path
'delete files
For Each file In Folder.files
wscript.echo file
fso.DeleteFile file, True
if Err.Number = 0 then
wscript.echo "OK"
else
wscript.echo "Fehler"
error = 1
end if
Next
'delete folders:
For Each Folder In Folder.SubFolders
wscript.echo Folder
fso.DeleteFolder Folder, True
if Err.Number = 0 then
wscript.echo "OK"
else
wscript.echo "Fehler"
error = 1
end if
Next
set Folder = nothing: set fso = nothing
if error = 0 then WScript.Quit(0)
if error = 1 then WScript.Quit(1)
({{pro_count}})
Beitrag bewerten:{{percentage}} % positiv
({{con_count}})
DANKE für deine Bewertung!
Fragen / Kommentare
(sortiert nach Bewertung / Datum) [alle Kommentare(neueste zuerst)]