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.
Right or should I make some correction?
THANKS
BYE
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)
Please log in to answer
Posted by:
anonymous_9363
15 years ago
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
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
Posted by:
anonymous_9363
15 years ago
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. :)
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.