none
Script Apagar Arquivos+pastas+subpastas RRS feed

  • Pergunta

  • Boa noite,

    Estou precizando de um script q tenha a função de apagar todos os arquivos, pastas e subpastsas de "C:\TMP" das estações de trabalho quando efetuar logoff...

    alguem tem ideia?

    dei uma pesquisada ja e vi alguns topicos mais infelizmente nao obtive exito...

    Sem mais,

    Dennis Fernandes.
    RN Automção.

    sexta-feira, 7 de março de 2008 02:11

Respostas

  • OPA...... nao preciza mais galera.. consegui aqui...

    ficou Dessa forma:

    Dim iCount,sRootPathToDelete,objFSO,objFolder,colSubFolders,BtnCode,WshShell2
    sRootPathToDelete="C:\TMP"
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFolder=objFSO.GetFolder(sRootPathToDelete)
    Set colSubfolders=objFolder.subfolders
    For Each objSubFolder in colSubFolders
    Set fld = objFSO.GetFolder(objSubFolder)
    For Each fl In fld.Files
    objFSO.deletefile fl.path , True
    'DoEvents

    Next
    objFSO.DeleteFile("C:\TMP\*.*"), True
    objFSO.DeleteFile(objSubFolder+"*.*"), True
    objFSO.DeleteFolder(objSubFolder.path)
    Next

    valeu!

    sexta-feira, 7 de março de 2008 03:25

Todas as Respostas

  • Eu consegui 1.. sendo q ele so está apagando as subpastas+arquivos das subpastas... so está faltando a "raiz" do c:\tmp.



    Dim iCount,sRootPathToDelete,objFSO,objFolder,colSubFolders,BtnCode,WshShell2
    sRootPathToDelete="C:\TMP"
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFolder=objFSO.GetFolder(sRootPathToDelete)
    Set colSubfolders=objFolder.subfolders
    For Each objSubFolder in colSubFolders
    Set fld = objFSO.GetFolder(objSubFolder)
    For Each fl In fld.Files
    objFSO.deletefile fl.path , True
    'DoEvents

    Next
    objFSO.DeleteFile(objSubFolder+"*.*"), True
    objFSO.DeleteFolder(objSubFolder.path)
    Next
    sexta-feira, 7 de março de 2008 03:11
  • OPA...... nao preciza mais galera.. consegui aqui...

    ficou Dessa forma:

    Dim iCount,sRootPathToDelete,objFSO,objFolder,colSubFolders,BtnCode,WshShell2
    sRootPathToDelete="C:\TMP"
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFolder=objFSO.GetFolder(sRootPathToDelete)
    Set colSubfolders=objFolder.subfolders
    For Each objSubFolder in colSubFolders
    Set fld = objFSO.GetFolder(objSubFolder)
    For Each fl In fld.Files
    objFSO.deletefile fl.path , True
    'DoEvents

    Next
    objFSO.DeleteFile("C:\TMP\*.*"), True
    objFSO.DeleteFile(objSubFolder+"*.*"), True
    objFSO.DeleteFolder(objSubFolder.path)
    Next

    valeu!

    sexta-feira, 7 de março de 2008 03:25
  • Obrigado e parabéns Dennis, também me achou!
    quinta-feira, 27 de setembro de 2012 13:58