Jump to content

Was wondering if someone could help me Make A Batch File That Deletes


Recommended Posts

Was wondering if someone could help me Make A Batch File That Deletes Files

Not sure if many can help but I am in IT, and run in to a certain program error all the time. The fix is deleting 4 files in their PC.

Example:

1.Delete the UCF folder located at C:\Documents and Settings\Username\Documentum

2.Delete the Java folder located at C:\Cache

3.Delete Temp internet Files - On IE

4.Delete Cookies - On IE

In Windows XP

Any suggestions?

Link to comment
Share on other sites


noobish atempt

not tested

paths taken from win7


echo off
:: removes the 2 folders
rd %userprofile%\Documentum\UCF
rd %systemdrive%\cache\Java
:: ie cache
del /f /q "%userprofile%\appdata\local\Temporary Internet Files" *.*
del /f /q "%userprofile%\appdata\local\microsoft\windows\Temporary Internet Files" *.*
del /f /q "%systemdrive%\users\default\appdata\local\Temporary Internet Files" *.*
del /f /q "%systemdrive%\users\default\appdata\local\microsoft\windows\Temporary Internet Files" *.*
del /f /q "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
del /f /q "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
del /f /q "%windir%\System32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
:: ie cookies
del /f /q %userprofile%\cookies *.*
del /f /q %appdata%\microsoft\windows\cookies *.*
del /f /q %systemdrive%\users\default\cookies *.*
del /f /q %systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\ServiceProfiles\LocalService\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\System32\config\systemprofile\AppData\Roaming\Microsoft\Windows\cookies *.*
exit

Edited by vinifera
Link to comment
Share on other sites

noobish atempt

not tested

paths taken from win7


echo off
:: removes the 2 folders
rd %userprofile%\Documentum\UCF
rd %systemdrive%\cache\Java
:: ie cache
del /f /q "%userprofile%\appdata\local\Temporary Internet Files" *.*
del /f /q "%userprofile%\appdata\local\microsoft\windows\Temporary Internet Files" *.*
del /f /q "%systemdrive%\users\default\appdata\local\Temporary Internet Files" *.*
del /f /q "%systemdrive%\users\default\appdata\local\microsoft\windows\Temporary Internet Files" *.*
del /f /q "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
del /f /q "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
del /f /q "%windir%\System32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*
:: ie cookies
del /f /q %userprofile%\cookies *.*
del /f /q %appdata%\microsoft\windows\cookies *.*
del /f /q %systemdrive%\users\default\cookies *.*
del /f /q %systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\ServiceProfiles\LocalService\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\Windows\cookies *.*
del /f /q %windir%\System32\config\systemprofile\AppData\Roaming\Microsoft\Windows\cookies *.*
exit

Very nice, will this work on XP and 7? I know some of the directories changed

thanks,

Link to comment
Share on other sites

Well, IMHO the chances of the posted batch to work on any of the two systems are pretty dim anyway, and the BAD news are that is potentially HIGHLY destructive :(.

What happens if the directories are not empty?

A /s parameter may be of use:

http://ss64.com/nt/rd.html

And I do have some BIG perplexities :unsure: on the PATHs/filenames given to the del command:

http://ss64.com/nt/del.html

I would try with something like:

del /f /q "%userprofile%\appdata\local\Temporary Internet Files\ *"

i.e. with the full path inside the quotes and a single asterisk, but as a matter of fact if you try on a command line:

md C:\mytest
md C:\mytest\mytestsub
echo test1>C:\mytest\mytestsub\mytest1.txt
echo test2>C:\mytest\mytestsub\mytest2.txt
echo test3>C:\mytest\mytest3.txt
del "C:\mytest"

you will see how you will be prompted with something like:

C:\mytest\*, Proceed (Y/N)?

(press N to the prompt).

Now try issuing:

CD /D C:\mytest
del "C:\mytest\mytestsub" *.*

You are now prompted with:

C:\mytest\mytestsub\*, Proceed (Y/N)?

this time press Y to the prompt, you will be immediately prompted:

C:\mytest\*.*, Proceed (Y/N)?

del accepts a LIST of files to be deleted, a line like this:

del /f /q "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" *.*

will quietly delete all files in "%windir%\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files" and then delete ALL FILES in CURRENT DIRECTORY :w00t::ph34r: .

jaclaz

Link to comment
Share on other sites

I wrote its untested

therefore I don't claim it would work or what it will do to a system :P

Well, with all due respect :), you should NOT post :realmad: - and expecially in response to someone evidently not famiiar with the command line or batches - an untested script with such a potential destructive power.

You do understand that if the user would have run that crappy batch in System directory or in Root he would likely have made the system unbootable/unrecoverable, do you? :unsure:

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...