1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to code a batch file to delete specific folder?

Discussion in 'Windows XP' started by Eric, Apr 26, 2010.

  1. Eric

    Eric Flightless Bird

    Does anyone have any suggestions on how to code a batch file to delete all
    files and sub trees under following directory?
    C:/Documents and Settings\Default User\Local Settings\Temp
    Thanks in advance for any suggestions
    Eric
     
  2. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "Eric" <Eric@discussions.microsoft.com> wrote in message
    news:F38A46FE-E7E2-4BAF-BFFE-1F3471E5EA20@microsoft.com...
    > Does anyone have any suggestions on how to code a batch file to delete all
    > files and sub trees under following directory?
    > C:/Documents and Settings\Default User\Local Settings\Temp
    > Thanks in advance for any suggestions
    > Eric


    Here you go:
    @echo off
    rd /s /q "C:/Documents and Settings\Default User\Local Settings\Temp"
    md "C:/Documents and Settings\Default User\Local Settings\Temp"

    Whether it is a wise idea to play around with the Default User profile
    folder is another question.
     
  3. Eric

    Eric Flightless Bird

    If any file is currently used under this directory, this batch file cannot
    delete them. Does it right?
    Thank you very much for suggestions
    Eric

    "Pegasus [MVP]" wrote:

    >
    >
    > "Eric" <Eric@discussions.microsoft.com> wrote in message
    > news:F38A46FE-E7E2-4BAF-BFFE-1F3471E5EA20@microsoft.com...
    > > Does anyone have any suggestions on how to code a batch file to delete all
    > > files and sub trees under following directory?
    > > C:/Documents and Settings\Default User\Local Settings\Temp
    > > Thanks in advance for any suggestions
    > > Eric

    >
    > Here you go:
    > @echo off
    > rd /s /q "C:/Documents and Settings\Default User\Local Settings\Temp"
    > md "C:/Documents and Settings\Default User\Local Settings\Temp"
    >
    > Whether it is a wise idea to play around with the Default User profile
    > folder is another question.
    >
    > .
    >
     
  4. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    Correct. There is next to nothing that will delete a file that is currently
    in use. However, it does not matter: The batch file I gave you will do what
    you asked for, within the restrictions imposed by the operating system.

    "Eric" <Eric@discussions.microsoft.com> wrote in message
    news:CF9973A0-D89D-45AA-BFDB-76CB5834A67D@microsoft.com...
    > If any file is currently used under this directory, this batch file cannot
    > delete them. Does it right?
    > Thank you very much for suggestions
    > Eric
    >
    > "Pegasus [MVP]" wrote:
    >
    >>
    >>
    >> "Eric" <Eric@discussions.microsoft.com> wrote in message
    >> news:F38A46FE-E7E2-4BAF-BFFE-1F3471E5EA20@microsoft.com...
    >> > Does anyone have any suggestions on how to code a batch file to delete
    >> > all
    >> > files and sub trees under following directory?
    >> > C:/Documents and Settings\Default User\Local Settings\Temp
    >> > Thanks in advance for any suggestions
    >> > Eric

    >>
    >> Here you go:
    >> @echo off
    >> rd /s /q "C:/Documents and Settings\Default User\Local Settings\Temp"
    >> md "C:/Documents and Settings\Default User\Local Settings\Temp"
    >>
    >> Whether it is a wise idea to play around with the Default User profile
    >> folder is another question.
    >>
    >> .
    >>
     

Share This Page