By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

Make A Batch File That Deletes Files

anoble1
100+
P: 225
Hi,

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
4.Delete Cookies

Any suggestions?
Nov 29 '12 #1
Share this Question
Share on Google+
5 Replies


zmbd
Expert Mod 5K+
P: 5,397
Hello,
Wow, an batch file... I remember when these were the only way to fly in the old DOS-1.0/3.0 days.
But I show my age ;)

Anyway, this is one of a few references available to the old notepad basher: http://www.computerhope.com/batch.htm I go with the tutorial in that batch files are not taught anymore and some (like myself) haven't used one in so long...

There are also other scripting languages and power-shell and the like; however, if as my I.T. does, the corperate types have some of these disabled. However, if you have the correct access rights, these old DOS batch files will work!
Nov 29 '12 #2

anoble1
100+
P: 225
Nice, couldn't figure out how to do the "Username" thing. Cause everyone's username is different.
Nov 29 '12 #3

zmbd
Expert Mod 5K+
P: 5,397
Oh, I should mention that "edit" more than likely isn't usually included in some if the newer versions of windows so you will have to use something else like notepad... just make sure to save the file with the "bat" extention.
Nov 29 '12 #4

P: 1
Create a text file, name it and change the extension to .bat

If you open a cmd prompt and type in "help" it will list all the acceptable commands.

use del or erase for files and rmdir for directories.

If you are unsure of the usage of a particular command, at the command prompt, type in the command followed by /? i.e. del /? will give you proper usage of del.

On the .bat file you created earlier, right click and select edit. Enter the commands and switches that you want to run, save it, then run it by double clicking the file.

The user folder can be accessed as %userprofile% so to remove the folder UCF, you would use RMDIR "%userprofile%\documentum\UCF".

I would definitely test this before putting it into production. :-)
Nov 29 '12 #5

zmbd
Expert Mod 5K+
P: 5,397
unrauew:
What information did you provide that was not already provided in my post and in the provided tutorial?

Also %userprofile% although should be a universal environment for the local drive ("C:") is not guaranteed to work at the PC level... In fact, if you type that shortcut into a windows explorer on my work pc you will be taken to the roaming profile folder share on the server - not the "c:\....\username\" on the local pc!
Nov 29 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.