/build/static/layout/Breadcrumb_cap_w.png

Script for deleting the files and the directories of an NTFS partition except one

HI

Putting in X virtual disk of Windows PE 2.1 this script, it should delete all files and all directories of an NTFS partition in which there is the \Users directory except this directory and its subdirectories.


@echo off

for %%I in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do (
if exist %%I:\Users set DVDDrive=%%I else (
echo not exist the %%I:\Users directory.
pause
goto :EOF)
)

pushd X:\Windows\System32

for /R %%f in (%DVDDrive%\) do (
if not "%%f" == "%DVDDrive%\Users" (attrib -rhsi *.* /s
del /s /q *.*)
)

popd


Right or should I make some correction?

THANKS

BYE

0 Comments   [ + ] Show comments

Answers (4)

Posted by: anonymous_9363 15 years ago
Red Belt
0
I don't think you can delete non-empty sub-directories with DEL, can you? You need KILLDIR or something like that. Does that exist on PE? If not, I'm sure you could locate a free utility to do the same job.

Batch is completely the wrong "language" for this job, IMO, but I'm not familiar with the PE envirnoment so I'm not sure what your alternatives might be.

EDIT:
Looks like VBS can be made available http://www.msfn.org/board/lofiversion/index.php/t16552.html
Posted by: Inabus 15 years ago
Second Degree Green Belt
0
You can delete subdirectories with Del.exe, you use Dell C:\AdminStudio Shared\*.* /S.

del /? gives you the other options available.

P
Posted by: anonymous_9363 15 years ago
Red Belt
0
DEL.EXE? Surely DEL is an internal command to the command processor, isn't it?

I just tested deleting the folder C:\Bin\Binn where the structure is C:\Bin\Binn\Binn\Binn and where the final folder contains 3 files. The command "ECHO Y|DEL C:\Bin\Binn /S" deleted the files but no folders. I used to do this stuff ad infinitum but the grey cells are now lost. I prefer script anyway. :)
Posted by: McRip 15 years ago
Orange Senior Belt
0

cmd.exe /c RD "%ProgramFiles%\DUMMYFOLDER" /S /Q


This deletes the complete folder with subfolders and all files in there in silent mode...

Very effective...

Cheers
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ