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

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

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

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

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

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

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

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

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

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

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 for2: Custom .bat .cmd files creation help.
Thread Forum
Unintended Creation of Files General Discussion
Solved 86 program files in new 64 bit custom install. General Discussion
custom .reg files, or windows install Customization
If I do a custom upgrade, how do I get my files back? Installation & Setup
Custom thumbnails for video files (mkv) Music, Pictures & Video

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 08:23 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33