• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

How to code a batch file to delete specific folder?

E

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
 
P

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.
 
E

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.
>
> .
>
 
P

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.
>>
>> .
>>
 
Top