Custom .bat .cmd files creation help.

Page 1 of 2 12 LastLast

  1. Posts : 14
    Windows 7 Pro 64-bit
       #1

    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 Computer


  2. Posts : 6,668
    Windows 7 x64
       #2

    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


  3. Posts : 14
    Windows 7 Pro 64-bit
    Thread Starter
       #3

    Maguscreed said:
    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


  4. Posts : 6,668
    Windows 7 x64
       #4

    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


  5. Posts : 14
    Windows 7 Pro 64-bit
    Thread Starter
       #5

    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


  6. Posts : 6,668
    Windows 7 x64
       #6

    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


  7. Posts : 126
    Windows 7 Pro 32bit / Windows 7 Professional
       #7

    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


  8. Posts : 14
    Windows 7 Pro 64-bit
    Thread Starter
       #8

    SundRance said:
    You could write a batch file deleting all the files you want to delete...
    Yes exactly! And how do I do that?
      My Computer


  9. Posts : 126
    Windows 7 Pro 32bit / Windows 7 Professional
       #9

    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 by SundRance; 13 Sep 2011 at 16:37.
      My Computer


  10. Posts : 742
    MS Windows 7 Ultimate 64-bit SP1
       #10

    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


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 10:49.
Find Us