views:

75

answers:

5

i have a litle project for which i would like to remove all files outside of and not needed by the c:\windows operating system. therefore i need to create a list of what i want to keep i.e. boot.ini c:\windows etc and then delete everything else. i have seen examples using forFile, but i can be sure that extension will be on the machine. does anyone have any ideas how i can create the exclude list and then do the delete?

A: 

Here's a quick stab at a list of top level folders you should not touch:

$Recycle.Bin
Documents and Settings [C:\Users]
inetpub
MSOCache
Program Files
Program Files (x86)
ProgramData
Recovery
System Volume Information
Users
Windows

On XP Documents and Settings is a folder, on Vista and 7 it's a link to the Users folder.

MSOCache is safe to delete as well. However, a lot of installer packages are cached there and used for various MS products updates/repairs. As such, I'd actually recommend keeping it.

Program Files (x86) is the redirected Program Files for 32-bit apps on 64-bit OS installs. However, I've seen applications that install in this folder instead of Program Files even on 32-bit OSes, so I'd advise on keeping it and manually inspecting its content to make a decision if it should be gone.

Update: There's no reliable way to list the OS files only. The list can vary widely between OS version, SKU, architecture, OS features installed, hardware drivers, OS updates and installed applications.

Franci Penov
sure thing - however what files are required to only run the operating system, if i want to remove all user data?
simondo
A: 

Don't forget to backup whichever method you implement.

:: you can define parameters so it know not include the folders you don't want and check it like so

IF "%2" == "" 
IF "%1" == "RunMyBatchFile" ^


FOR %%i IN (""%filter%) ^  ::directory name goes in here that you want to iterate over todelete
DO (^::Do your stuff, make sure to use echo to see the output on the cmd
) ^
VoodooChild
thanks for your advicelooking at the list below ive going with For /F %I in ('dir /s /b "USERPROFILE%") do Del %Iwhich should, if the user puts their content in their user profile, remove it and not stop on errors.thank again
simondo
A: 

In addition to the comments about other folders than c:\Windows, a lot of common windows components go in Program Files\Common Files, and the application folders under Program Files are likely to have drivers that Windows won't boot normally without; AntiVirus, graphics and other non-default hardware drivers.

Here be dragons.

Ron Ruble
dragons indeed! basically i want to remove the user content, while leaving the operating sytem alone, avoiding OS warningsthnx
simondo
A: 

let me expand on my pal, my car got borken into, apart from randomly trashing it, the took some DVDs from my glove compartment, nothing rude, but it gave me an idea about trashing their computer when they load the DVD stolen from my car. so now you understand!! :-) i leave a saucy titled dvd in the glove compartment (in the full knowledge of the wife of course...) and if it get broken into again, they'll have a nice little surprise when they try to watch saucy vixens on their laptop!! kinda tempting fate i know, but the though of what will be happeing will be sweet

simondo
A: 

If what you want is to get rid of user data files, you only need to look in a couple of places, such as %USERPROFILE%\AppData. The actual directory names vary with the OS (XP/Vista/7).

But don't do it to the Administrator, or yourself!

egrunin