Looping a sub script RRS feed

  • Question

  • how can i get this script to run in a loop continuously? So that when the files are created again, they get deleted.
    I've tried different loop commands, but can't get it to work.


    On Error Resume Next

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set oshell = CreateObject("WScript.Shell")
    TempFolder=oshell.ExpandEnvironmentStrings("%userprofile%") & "\appdata\local\temp"

    ShowSubFolders objFSO.GetFolder(TempFolder)

    Sub ShowSubFolders(Folder)

    For Each file In Folder.Files
    Set objCurFile = objFSO.GetFile(file)

    If Instr(ucase(objCurFile.Name), UCase("state")) Then objCurFile.Delete


    For Each Subfolder in Folder.SubFolders
    ShowSubFolders Subfolder


    End Sub

    • Moved by Reed KimbleMVP Tuesday, May 15, 2018 4:30 PM VBS in VB.Net
    • Moved by Bill_Stewart Friday, July 27, 2018 8:18 PM This is not "debug/fix/rewrite my script for me" forum
    Friday, May 11, 2018 4:26 PM

All replies