• no need for xp_cmdshell or any other nasties. Create a sql server job step as activex script and set to VBS. The code i use is as follows

    Option Explicit

    'Delete all SQL Server backup files more than 5 days old

    Dim oFS, oSQLBackupFol, oFol, oFil

    Dim sPattern

    sPattern = "*.bak"

    Set oFS = CreateObject("Scripting.FileSystemObject")

    Set oSQLBackupFol = oFS.GetFolder("drive:\path") 'Change this as appropriate

    For Each oFol IN oSQLBackupFol.SubFolders 'get subfolders of the above path

    For Each oFil in oFol.Files 'get each file in subfolder

    If oFil.DateCreated < Now-5 then 'Change this as appropriate

    If ucase(right(oFil.name, 4)) = ".BAK" then

    oFil.Delete

    End If

    End If

    Next

    Next

    Set oFS = nothing

    Set oSQLBackupFol = nothing

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉