Problem: You have an old discarded instances of failed Windows 7 installs. You can rename the directories, but they still clutter your hard drive, and they are very hard to get rid of.
I simply can’t take this painful and slow process of deleting huge system directories under Windows 7. Remember this endless stream of errors, and warnings, and skips. The same task in Win XP only takes a few seconds. But under Windows 7, it is a project of its own. Pain!
Finally, my patience ran out. I decided to write a script. And it it worked!
Delete Windows System Directories
Here is a fantastic way to delete huge Windows 7 system directories:
Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7DATA\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7DATA\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7DATA\*.* /GRANT=Everyone=F Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7DATA\*.* /GRANT=Everyone=F DEL R:\zS7-R3-0W7\z0W7DATA\*.* /F /S /Q /A RD R:\zS7-R3-0W7\z0W7DATA /Q /S Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7PRO86\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7PRO86\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7PRO86\*.* /GRANT=Everyone=F Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7PRO86\*.* /GRANT=Everyone=F DEL R:\zS7-R3-0W7\z0W7PRO86\*.* /F /S /Q /A RD R:\zS7-R3-0W7\z0W7PRO86 /Q /S Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7PROG\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7PROG\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7PROG\*.* /GRANT=Everyone=F Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7PROG\*.* /GRANT=Everyone=F DEL R:\zS7-R3-0W7\z0W7PROG\*.* /F /S /Q /A RD R:\zS7-R3-0W7\z0W7PROG /Q /S Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7WIN\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7WIN\*.* /SETOWNER=Everyone Q:\Data\Batch\SUBINACL.EXE /subdirectories R:\zS7-R3-0W7\z0W7WIN\*.* /GRANT=Everyone=F Q:\Data\Batch\SUBINACL.EXE /file R:\zS7-R3-0W7\z0W7WIN\*.* /GRANT=Everyone=F DEL R:\zS7-R3-0W7\z0W7WIN\*.* /F /S /Q /A RD R:\zS7-R3-0W7\z0W7WIN /Q /S
This script will delete unneeded directories from old Windows 7 installs. With just one click. This script will delete Program File, and Users and Windows without your interference. You just need to adjust directory names to your needs.
Observe, what each section does:
First 2 lines set owner to Everyone for both directories and files.
Next 2 lines are granting Full rights to Everyone for both directories and files.
Line 5 in each section deletes all files and directories inside given Windows system folder.
Finally, line 6 deletel the directory itself.
For this script you need to download a free SUBINACL.EXE utility from Microsoft. It is dated 2004-06-11, but it still works on all latest Windows versions, including x64.
Move / Copy Windows System Directories
Next logical question, how do I copy / move these massive Windows directories from one drive to another?
That is easy to – using ROBOCOPY. Here is a script:
RoboCopy C:\nW7DATA R:\zS7-R3-0W7\0W7DATA /e /zb /copyall /r:0 /w:0 /xJ RoboCopy C:\nW7PROG R:\zS7-R3-0W7\0W7PROG /e /zb /copyall /r:0 /w:0 /xJ RoboCopy C:\nW7PRO86 R:\zS7-R3-0W7\0W7PRO86 /e /zb /copyall /r:0 /w:0 /xJ RoboCopy C:\nW7WIN R:\zS7-R3-0W7\0W7WIN /e /zb /copyall /r:0 /w:0 /xJ
Please note, what each line does. 4 lines copy Program Files, Users (Data) and Windows directories to a spare drive R:
Switch /E instructs to copy sub-directories, including Empty ones.
Switch /ZB allows to copy even if there is an “Access Denied” violation.
Switch /COPYALL allows to copy all file info and attributes along with the file itself.
Switch /R:0 sets retries to zero seconds.
Switch /W:0 sets wait to zero seconds.
Finally, switch /XJ excludes Junction Points – very important!
Documentation suggests that there is a switch /MOVE that will delete files and directories after COPY.
I did not test this option yet. It would be nice, if it worked.
All in all, Microsoft does have a solid scripting solution for file management in Windows 7 for serious users.
Note: [ 2015-03-15 SU] Just tested this on windows 7 x64 Enterprise Edition. Script cleanly removed all 4 system directors, and it took about 7 minutes to do. Fantastic!
X:\Util\SUBINACL.EXE /subdirectories C:\1E7DATA\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /file C:\1E7DATA\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /subdirectories C:\1E7DATA\*.* /GRANT=Everyone=F X:\Util\SUBINACL.EXE /file C:\1E7DATA\*.* /GRANT=Everyone=F DEL C:\1E7DATA\*.* /F /S /Q /A RD C:\1E7DATA /Q /S X:\Util\SUBINACL.EXE /subdirectories C:\1E7PRO86\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /file C:\1E7PRO86\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /subdirectories C:\1E7PRO86\*.* /GRANT=Everyone=F X:\Util\SUBINACL.EXE /file C:\1E7PRO86\*.* /GRANT=Everyone=F DEL C:\1E7PRO86\*.* /F /S /Q /A RD C:\1E7PRO86 /Q /S X:\Util\SUBINACL.EXE /subdirectories C:\1E7PROG\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /file C:\1E7PROG\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /subdirectories C:\1E7PROG\*.* /GRANT=Everyone=F X:\Util\SUBINACL.EXE /file C:\1E7PROG\*.* /GRANT=Everyone=F DEL C:\1E7PROG\*.* /F /S /Q /A RD C:\1E7PROG /Q /S X:\Util\SUBINACL.EXE /subdirectories C:\1E7WIN\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /file C:\1E7WIN\*.* /SETOWNER=Everyone X:\Util\SUBINACL.EXE /subdirectories C:\1E7WIN\*.* /GRANT=Everyone=F X:\Util\SUBINACL.EXE /file C:\1E7WIN\*.* /GRANT=Everyone=F DEL C:\1E7WIN\*.* /F /S /Q /A RD C:\1E7WIN /Q /S
Once again: be very, very careful with this powerful stuff.
1 Trackback / Pingback
" class=""> Windows 7 – How to Rename All System Directories | Domain Web Center