MSFN Forum: Was wondering if someone could help me Make A Batch File That Deletes - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Was wondering if someone could help me Make A Batch File That Deletes Rate Topic: -----

#1 User is offline   anoble1 

  • Group: Members
  • Posts: 7
  • Joined: 29-November 12
  • OS:XP Pro x86
  • Country: Country Flag

Posted 29 November 2012 - 02:13 PM

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?


#2 User is offline   vinifera 

  • <°)))><
  • PipPipPipPip
  • Group: Members
  • Posts: 585
  • Joined: 27-August 09
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 29 November 2012 - 03:03 PM

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


This post has been edited by vinifera: 29 November 2012 - 06:16 PM


#3 User is online   5eraph 

  • Update Packrat
  • Group: Supreme Sponsor
  • Posts: 954
  • Joined: 04-July 05
  • OS:XP Pro x64
  • Country: Country Flag

Posted 29 November 2012 - 06:05 PM

...except remark lines start with REM or a double colon ( :: ) instead of a semicolon ( ; ). ;)

This post has been edited by 5eraph: 29 November 2012 - 06:05 PM


#4 User is offline   vinifera 

  • <°)))><
  • PipPipPipPip
  • Group: Members
  • Posts: 585
  • Joined: 27-August 09
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 29 November 2012 - 06:16 PM

corrected :D

#5 User is offline   anoble1 

  • Group: Members
  • Posts: 7
  • Joined: 29-November 12
  • OS:XP Pro x86
  • Country: Country Flag

Posted 30 November 2012 - 12:26 PM

View Postvinifera, on 29 November 2012 - 03:03 PM, said:

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,

#6 User is offline   anoble1 

  • Group: Members
  • Posts: 7
  • Joined: 29-November 12
  • OS:XP Pro x86
  • Country: Country Flag

Posted 30 November 2012 - 12:49 PM

I ran that on my 7 machine and like 10 icons disappeared from my desktop. Not sure what caused that.

#7 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,457
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 30 November 2012 - 01:00 PM

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:

Quote

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:

Quote

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:

Quote

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

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

Quote

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


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

Quote

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

#8 User is offline   vinifera 

  • <°)))><
  • PipPipPipPip
  • Group: Members
  • Posts: 585
  • Joined: 27-August 09
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 30 November 2012 - 01:31 PM

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

ccleaner is better to use

This post has been edited by vinifera: 30 November 2012 - 01:32 PM


#9 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 30 November 2012 - 01:55 PM

RD/S/Q "%USERPROFILE%\Documentum\UCF"
RD/S/Q %SYSTEMDRIVE%\Cache\Java
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 10


#10 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,457
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 01 December 2012 - 05:02 AM

View Postvinifera, on 30 November 2012 - 01:31 PM, said:

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy