Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Custom .bat .cmd files creation help.

13 Sep 2011   #1
asdf123

Windows 7 Pro 64-bit
 
 
Custom .bat .cmd files creation help.

Hi,
I want to create a .bat or some self executable file that will clear my files on each shutdown or startup. Like all temp folders, some files like desktop.ini, temporary files created by programs, ect.
Is this possible? If it is, how should I go about it?


My System SpecsSystem Spec
.

13 Sep 2011   #2
Maguscreed

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

You can set ccleaner to do all of that.
CCleaner - Command-line parameters
Then just create a task that will run it at shutdown.
This will be much easier and more reliable than trying to name all the temp folders and logs in a batch file.
My System SpecsSystem Spec
13 Sep 2011   #3
asdf123

Windows 7 Pro 64-bit
 
 

Quote   Quote: Originally Posted by Maguscreed View Post
You can set ccleaner to do all of that.
CCleaner - Command-line parameters
Then just create a task that will run it at shutdown.
This will be much easier and more reliable than trying to name all the temp folders and logs in a batch file.
Yes, I use this program but it doesn't provide exactly what I'm aiming for.
I was planning to create a batch file to remove all the files that CCleaner doesn't remove.
Is there a template or a tutorial of somekind where I can be shown how to do that kind of stuff?
My System SpecsSystem Spec
.


13 Sep 2011   #4
Maguscreed

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

Schedule a task

It's really pretty simple to create a task based on a system event. i.e. shutdown.
Or you could create a shortcut that was pointed to c:\program files (x86)\ccleaner\cleaner.exe /auto /shutdown
and simply use the shortcut to turn off the machine.
My System SpecsSystem Spec
13 Sep 2011   #5
asdf123

Windows 7 Pro 64-bit
 
 

The thing is I don't want to use any programs.
I want to create a file .bat .cmd, script, whatever. That I will add to MSconfig, GPEdit and I will process my tasks. The Task Scheduler and CCleaner is a great tool, but it does not have a tool that I can point an exact folder or a file and it will be deleted on the next restart/shutdown.
My System SpecsSystem Spec
13 Sep 2011   #6
Maguscreed

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

I'm going to have to admit I'm apparently misunderstanding what it is you want.
Hopefully someone will drop by with what you need.
My System SpecsSystem Spec
13 Sep 2011   #7
SundRance

Windows 7 Pro 32bit / Windows 7 Ultimate x64
 
 

You could write a batch file deleting all the files you want to delete, and place a link to that batch file in the Startup folder of the Start Button. That will run the batch file every time you boot Windows. You can also point to any files that CCleaner is missing under Options, Include. I think you may need to show all files before using the Include feature, or you won't be able to browse to the folders they're in.

You will have to be very careful when writing the batch file to make sure you have path and file names correct. These types of batch files can be very unforgiving.

Best Wishes,
RȘnce

edit sentence structure
My System SpecsSystem Spec
13 Sep 2011   #8
asdf123

Windows 7 Pro 64-bit
 
 

Quote   Quote: Originally Posted by SundRance View Post
You could write a batch file deleting all the files you want to delete...
Yes exactly! And how do I do that?
My System SpecsSystem Spec
13 Sep 2011   #9
SundRance

Windows 7 Pro 32bit / Windows 7 Ultimate x64
 
 

First off, locate all the separate files. DEL is the delete command ...

@echo off
DEL C:\SELECTED FOLDER\FILENAME.EXT
DEL C:\ANOTHER SELECTED FOLDER\FILENAME.EXT

Where EXT is the file extension. To clean out a particular folder of all files use FILENAME.*

correction: To clean out a whole folder of files use *.*
*.* acts as a wildcard and will delete files of any name and any extension. Sorry about the edit.

Create a new Notepad file, rename the extension .BAT and edit the file with Notepad. You can add as many del lines as you wish. Case doesn't matter but path statements and file names are very important. You can place the batch file in your User Name folder, and when you open a CMD session the file will run from there. Copy the file, and paste a shortcut into your Start Menu Startup folder. The file should then run whenever you boot Windows.

PS: a good test might be to substitute DIR (directory or list) in place of the DEL command to make sure you have all paths and file names correct. Once you are sure of yourself use Find and Replace to switch out the DIR command for the DEL (delete) command.

I use a number of utility batch files myself, for backing up and syncing copies of files from my laptop to my desktop computer. Here's a batch file resource. I'm sure there are scores of others on the Web:

The Command Line in Windows: Batch file basics

Let me know if I have mis-understood your question or need something else.

RȘnce
My System SpecsSystem Spec
13 Sep 2011   #10
rraod

MS Windows 7 Ultimate 64-bit SP1
 
 

This is a sample batch file.
------------------------------
Create a txt file and copy the contents below into it and save as RemoveJpgMp3.cmd. When executed it will delete the jpg and mp3 files and also deletes the folders also. Modify the batchfile to suit your needs.

'This is a batch file to delete all the jpg files from Pictures folder and mp3 files from My Music folder. This batch file also deletes the Pictures and My Music folders.
@echo off
cls
del c:\users\asdf123\Pictures\*.jpg
del "c:\users\asdf123\My Music\*.mp3"
rd c:\users\asdf123\Pictures
rd "c:\users\asdf123\My Music"
echo Done


BATCH FILE EXAMPLES

The above link to a website gives you some sample batchfiles you can study and modify to suit your needs. Batch file programming needs learning and practice.
My System SpecsSystem Spec
Reply

 Custom .bat .cmd files creation help.




Thread Tools





Similar help and support threads
Thread Forum
Custom Genres for Music Files
I am in the process of revamping my music files into a better database. For right now, I'm just doing it through the windows folders. Since the files are MP3, the folders know they are music and it gives the options of Song Title, Artist, Genre, etc. When entering a genre, there are some...
Customization
Unintended Creation of Files
Hey guys, I frequently like to pull Notepad up, jot down my thoughts kind of like a journal thing, and then store them in a special folder. There's no special organization yet, they literally are just kind of my random thoughts that I'd like to come back to without forgetting about them, and if...
General Discussion
custom .reg files, or windows install
Hey sevenforums, first time poster Just wondering if you are able to make a custom registry file (or something of the like) in order to apply certain settings to a new windows 7 x64 installation? i wipe my drive often, and i use Ninite for a few applications, but theres also some settings i...
Customization
If I do a custom upgrade, how do I get my files back?
Hi there! :) I'm going to be a university student at Indiana University in the fall, so during orientation I picked up a student version of Windows 7 Ultimate for my HP Compaq laptop, which I bought back when Vista was brand new --I cant afford a new laptop right now, and the hardware is still...
Installation & Setup

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 13:09.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App