Custom .bat .cmd files creation help.

asdf123

New member
Local time
3:33 PM
Messages
14
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 Computer

OS
Windows 7 Pro 64-bit
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 Computer

Computer Manufacturer/Model Number
Insane hobo technologies. ;-)
OS
Windows 7 x64
CPU
Intel i7 2600k
Motherboard
Asrock z68 extreme 4 gen 3
Memory
G.skill Ripjaw 16gigs @ 1866
Graphics Card(s)
Nvidia gtx580 (evga)
Sound Card
Integrated HD audio + hdmi
Monitor(s) Displays
24" ASUS widescreen + 42" insignia
Screen Resolution
1080p (1920x1080)
Hard Drives
128 Samsung 830
256 Samsung 840
3 x 1tb storage drive (various)
1 western digital 1tb (eSATA)
1 Seagate 1tb (eSATA)
PSU
1 kilowatt SLI/Crossfire rated Silverstone modular
Case
NZXT Phantom + additional 220 fan
Cooling
Zalmann
Keyboard
Microsoft wireless 3000 (v2)
Mouse
MS - wireless 5000 (bluetrack)
Internet Speed
depends on if you ask me or my provider.
Other Info
The above information is provided as is, and the author assumes no responsibility for issues it may cause with your sanity or fanboyism.
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 Computer

OS
Windows 7 Pro 64-bit
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 Computer

Computer Manufacturer/Model Number
Insane hobo technologies. ;-)
OS
Windows 7 x64
CPU
Intel i7 2600k
Motherboard
Asrock z68 extreme 4 gen 3
Memory
G.skill Ripjaw 16gigs @ 1866
Graphics Card(s)
Nvidia gtx580 (evga)
Sound Card
Integrated HD audio + hdmi
Monitor(s) Displays
24" ASUS widescreen + 42" insignia
Screen Resolution
1080p (1920x1080)
Hard Drives
128 Samsung 830
256 Samsung 840
3 x 1tb storage drive (various)
1 western digital 1tb (eSATA)
1 Seagate 1tb (eSATA)
PSU
1 kilowatt SLI/Crossfire rated Silverstone modular
Case
NZXT Phantom + additional 220 fan
Cooling
Zalmann
Keyboard
Microsoft wireless 3000 (v2)
Mouse
MS - wireless 5000 (bluetrack)
Internet Speed
depends on if you ask me or my provider.
Other Info
The above information is provided as is, and the author assumes no responsibility for issues it may cause with your sanity or fanboyism.
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 Computer

OS
Windows 7 Pro 64-bit
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 Computer

Computer Manufacturer/Model Number
Insane hobo technologies. ;-)
OS
Windows 7 x64
CPU
Intel i7 2600k
Motherboard
Asrock z68 extreme 4 gen 3
Memory
G.skill Ripjaw 16gigs @ 1866
Graphics Card(s)
Nvidia gtx580 (evga)
Sound Card
Integrated HD audio + hdmi
Monitor(s) Displays
24" ASUS widescreen + 42" insignia
Screen Resolution
1080p (1920x1080)
Hard Drives
128 Samsung 830
256 Samsung 840
3 x 1tb storage drive (various)
1 western digital 1tb (eSATA)
1 Seagate 1tb (eSATA)
PSU
1 kilowatt SLI/Crossfire rated Silverstone modular
Case
NZXT Phantom + additional 220 fan
Cooling
Zalmann
Keyboard
Microsoft wireless 3000 (v2)
Mouse
MS - wireless 5000 (bluetrack)
Internet Speed
depends on if you ask me or my provider.
Other Info
The above information is provided as is, and the author assumes no responsibility for issues it may cause with your sanity or fanboyism.
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 Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Precision M6500 / Dell Insprion 3847
OS
Windows 7 Pro 32bit / Windows 7 Professional
CPU
Intel Core i7-620M Duel Core 2.66GHz / Intel Core i5-4460
Memory
4.0 GB / 8.0 GB
Graphics Card(s)
1.0 GB NVIDIA Quadro FX 2800M / Intel HD Graphics
Screen Resolution
1440x900 / 1920x1080
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
 
Last edited:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Precision M6500 / Dell Insprion 3847
OS
Windows 7 Pro 32bit / Windows 7 Professional
CPU
Intel Core i7-620M Duel Core 2.66GHz / Intel Core i5-4460
Memory
4.0 GB / 8.0 GB
Graphics Card(s)
1.0 GB NVIDIA Quadro FX 2800M / Intel HD Graphics
Screen Resolution
1440x900 / 1920x1080
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 Computer

Computer Manufacturer/Model Number
Toshiba Satellite P775-S7232
OS
MS Windows 7 Ultimate 64-bit SP1
CPU
i5-2410M 2.3GHz (2.9GHz Turbo-Boost) Sandy Bridge 32nm
Motherboard
Toshiba PHRAA ver. PSBY1U-00F003
Memory
4GB+4GB Samsung DDR3 PC3-10700 (1333 MHz)
Graphics Card(s)
Video Intel(R) HD Graphics Family, 1696MB available memory
Sound Card
Realtek High Definition Audio version=6.0.1.6323
Monitor(s) Displays
17.3 " Trubrite TFT LCD, LED Backlit
Screen Resolution
1600x900 32 bit, Native support for 720P content
Hard Drives
TOSHIBA MK6476GSXN
580.614 [GB] partitioned C: 80GB and D: 500GB with hidden recovery partitons.

Spare bay for 2nd HDD but no SATA connector :-(
PSU
Toshiba AC/DC Adapter
Case
Notebook
Cooling
Built-in Fan
Keyboard
Premium Raised Tile keyboard
Mouse
Logitech M215 wireless mouse
Internet Speed
Not fast enough
Other Info
Built-in Harman Kardon speakers with Dolby Advanced Audio, Waves MaxxAudio® 3. HDMI, 1xUSB3+3xUSB2 ports, WebCam, Battery life 4hrs 11mins, 4GB Readyboost SDHC card, WD My Book Essential Ext HDDs 2 TB, 2x1TB, My Passport SE 1TB and WDTV 1st Gen for Multimedia playing on a Sony Wega 32" LCD.
Recent addition to my toys are Asus Transformer Pad TF300T with 32GB onboard sd card + 32GB microsd card.
Thanks guys. I will look into this. One more thing: is there a batch file command to delete all files named i.e "XYZ.EXT" on whole drive "C:\" and subfolders? For example if I wanted to delete all *.tmp files on C:\ without pointing to each folder and subfolder.
 

My Computer

OS
Windows 7 Pro 64-bit
This is the help for del command on Command window or in a batch file.

C:\>del /?
Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows:
The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

You can use the command
Del C:\*.tmp /S /Q

to delete all the temp files with extension tmp on C: drive and all the subdirectories (/S) and without asking you for confirmation (/Q).

To change the drive replace C: with the correct drive letter.
 

My Computer

Computer Manufacturer/Model Number
Toshiba Satellite P775-S7232
OS
MS Windows 7 Ultimate 64-bit SP1
CPU
i5-2410M 2.3GHz (2.9GHz Turbo-Boost) Sandy Bridge 32nm
Motherboard
Toshiba PHRAA ver. PSBY1U-00F003
Memory
4GB+4GB Samsung DDR3 PC3-10700 (1333 MHz)
Graphics Card(s)
Video Intel(R) HD Graphics Family, 1696MB available memory
Sound Card
Realtek High Definition Audio version=6.0.1.6323
Monitor(s) Displays
17.3 " Trubrite TFT LCD, LED Backlit
Screen Resolution
1600x900 32 bit, Native support for 720P content
Hard Drives
TOSHIBA MK6476GSXN
580.614 [GB] partitioned C: 80GB and D: 500GB with hidden recovery partitons.

Spare bay for 2nd HDD but no SATA connector :-(
PSU
Toshiba AC/DC Adapter
Case
Notebook
Cooling
Built-in Fan
Keyboard
Premium Raised Tile keyboard
Mouse
Logitech M215 wireless mouse
Internet Speed
Not fast enough
Other Info
Built-in Harman Kardon speakers with Dolby Advanced Audio, Waves MaxxAudio® 3. HDMI, 1xUSB3+3xUSB2 ports, WebCam, Battery life 4hrs 11mins, 4GB Readyboost SDHC card, WD My Book Essential Ext HDDs 2 TB, 2x1TB, My Passport SE 1TB and WDTV 1st Gen for Multimedia playing on a Sony Wega 32" LCD.
Recent addition to my toys are Asus Transformer Pad TF300T with 32GB onboard sd card + 32GB microsd card.
Okay,
How do I delete the "desktop.ini" files. I've tried the line
"del /s /q /F "C:\desktop.ini" and it doesn't work. It deletes only some of the desktop.ini files not all of them (not talking about the Windows protected desktop.ini files).
 

My Computer

OS
Windows 7 Pro 64-bit
Desktop.ini files are used for customizing things like the folder's icon and localized name. Usually they have a system and hidden attributes set so that they are not visible.These files are small files and does not take up much space and best left alone.

I used to clean the desktop.ini and thumbs.db in Windows XP very religiously. But got fed-up as these files are getting created by windows again on next reboot. Hence just set the protected operating system files to be hidden and show hidden files and folders....(out of sight - out of mind). In Windows 7 I stopped bothering about these files.

If you still wants to delete these files try the below commands.
attrib -h -s C:\desktop.ini /S
del C:\desktop.ini /S /Q
 

My Computer

Computer Manufacturer/Model Number
Toshiba Satellite P775-S7232
OS
MS Windows 7 Ultimate 64-bit SP1
CPU
i5-2410M 2.3GHz (2.9GHz Turbo-Boost) Sandy Bridge 32nm
Motherboard
Toshiba PHRAA ver. PSBY1U-00F003
Memory
4GB+4GB Samsung DDR3 PC3-10700 (1333 MHz)
Graphics Card(s)
Video Intel(R) HD Graphics Family, 1696MB available memory
Sound Card
Realtek High Definition Audio version=6.0.1.6323
Monitor(s) Displays
17.3 " Trubrite TFT LCD, LED Backlit
Screen Resolution
1600x900 32 bit, Native support for 720P content
Hard Drives
TOSHIBA MK6476GSXN
580.614 [GB] partitioned C: 80GB and D: 500GB with hidden recovery partitons.

Spare bay for 2nd HDD but no SATA connector :-(
PSU
Toshiba AC/DC Adapter
Case
Notebook
Cooling
Built-in Fan
Keyboard
Premium Raised Tile keyboard
Mouse
Logitech M215 wireless mouse
Internet Speed
Not fast enough
Other Info
Built-in Harman Kardon speakers with Dolby Advanced Audio, Waves MaxxAudio® 3. HDMI, 1xUSB3+3xUSB2 ports, WebCam, Battery life 4hrs 11mins, 4GB Readyboost SDHC card, WD My Book Essential Ext HDDs 2 TB, 2x1TB, My Passport SE 1TB and WDTV 1st Gen for Multimedia playing on a Sony Wega 32" LCD.
Recent addition to my toys are Asus Transformer Pad TF300T with 32GB onboard sd card + 32GB microsd card.
If ANY of the sytem files bother me, it's those damn thumbs.db files. Trying to delete a folder that contains (or even contained) any type a graphic - especially across systems - one computer to another - is a PITA.

STILL: Windows 7 is a good OS and the thumbs data bases help speed up browsing folders. INI files are important too, and store display information. I find it best to NOT display hidden files, and also keep hidden protected files and Windows seems to function pretty well. Only when I am really re-arranging things do the thumbs files give me grief.

Best Wishes, and be careful with that DEL command,
Rªnce
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Precision M6500 / Dell Insprion 3847
OS
Windows 7 Pro 32bit / Windows 7 Professional
CPU
Intel Core i7-620M Duel Core 2.66GHz / Intel Core i5-4460
Memory
4.0 GB / 8.0 GB
Graphics Card(s)
1.0 GB NVIDIA Quadro FX 2800M / Intel HD Graphics
Screen Resolution
1440x900 / 1920x1080
Back
Top