Solved Making simple bat files

ilikefree

Vista Guru
Gold Member
Could some knowledgeable person please tell me how to make a simple program that would be run once to delete all the smut off my computer (in 2 folders) when it is run.
The reason is I want to leave this computer to someone and make it so they can delete folders without having to look for them.
Don't want to shock my sister too much.
I thought of a bat file but don't know enough about them @Echo% etc.
I have looked at some sites that give examples of bat files but don't explain what all the symbols mean and how to use them.
I like the idea of writing it in Notebook as no other programs are needed.
 

My Computer

System One

  • Manufacturer/Model
    Lenovo Thinkpad T400
    CPU
    Intel Mobile Core 2 Duo P8700 @ 2.53GHz
    Motherboard
    LENOVO 64734VM
    Memory
    2.00GB Single-Channel DDR3 @ 531MHz
    Graphics Card(s)
    Intel Mobile Intel 4 Series Express Chipset Family
    Sound Card
    Conexant 20561 SmartAudio HD
    Monitor(s) Displays
    15 inch
    Screen Resolution
    1280 x 800
    Hard Drives
    1x 180GB Intel 530 series SSD
    1 x 120GB Hitachi 5400rmp
    1 x 650GB Western Digital Elements 5400rpm
    1x 1Tb Western Digital Elements 5400rpm
    Internet Speed
    Medium for New Zealand
    Other Info
    Weakest part of my computer is the graphics chipset.
    Only ever used a laptop.
    Also use USB Freeview TV Card
    Lenovo Docking Station
    External Speakers
    Other bits a pieces as needed
Hello,

I will write it for you and explain it if you tell me exactly what you want it to do :)

Richard
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Thanks very much for the offer I have PM you to tell you what I need.Ta
 

My Computer

System One

  • Manufacturer/Model
    Lenovo Thinkpad T400
    CPU
    Intel Mobile Core 2 Duo P8700 @ 2.53GHz
    Motherboard
    LENOVO 64734VM
    Memory
    2.00GB Single-Channel DDR3 @ 531MHz
    Graphics Card(s)
    Intel Mobile Intel 4 Series Express Chipset Family
    Sound Card
    Conexant 20561 SmartAudio HD
    Monitor(s) Displays
    15 inch
    Screen Resolution
    1280 x 800
    Hard Drives
    1x 180GB Intel 530 series SSD
    1 x 120GB Hitachi 5400rmp
    1 x 650GB Western Digital Elements 5400rpm
    1x 1Tb Western Digital Elements 5400rpm
    Internet Speed
    Medium for New Zealand
    Other Info
    Weakest part of my computer is the graphics chipset.
    Only ever used a laptop.
    Also use USB Freeview TV Card
    Lenovo Docking Station
    External Speakers
    Other bits a pieces as needed
how can i make this attached file open only 1 IE window and 14 tabs?
 

Attachments

  • 5.bat
    809 bytes · Views: 94

My Computer

System One

  • Manufacturer/Model
    gateway/m6881
    CPU
    centrino core 2 duo 2.2ghz T7500
    Memory
    3GB
    Hard Drives
    500GB WD
    Mouse
    logitech
    Internet Speed
    fios 35MB not!!!!

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Hello,

I have done it for you. Please be very careful, as this batch file is live, and "testing it out" will complete the operation you have asked me to get done for you, so be careful. I have properly tested it. I have included everything below. All you need to do is make a batch file with the extension of .bat, and save it anywhere. Right click on the batch file, and click Edit. Paste in the code below and save the notepad document. Now the batch file will work, so be careful. Files will not be sent to the recycle bin, but be immediately deleted.

I have put in a safeguard "Press any key to begin:" and so if you do accidentally run it, immediately close it with the Red X and do not press any key, as you can start it with any key, not just enter.

As you asked for, it will self destruct once it has completed and completion has been acknowledged. You may call it anything, as I have not hard coded to a particular name, just "whatever name it runs under, i.e. %0.

I do not know how long it will take, it could take up to 20 minutes, or be instant, so I have explained both possibilities.

If you want anything changed, or anything added, do not be afraid to ask.

The Code:

Code:
@echo off
echo Converting computer to new user...
echo.
echo NOTE: This operation may take up to 20 minutes. Please do not interrupt this 
echo operation, or use the computer during this time. Do not worry if this operation
echo takes a much shorter time, this is fine.
echo.
echo Press any key to begin:
pause > nul
echo.
echo Working...
echo.
rmdir /s /q C:\Users\username\Videos\R18\ > nul
rmdir /s /q C:\Users\username\Pictures\"Slide Shows"\ > nul
echo Finished!
echo.
pause
del %0
How it works (line by line):


  • @ echo off: Switch off display commands on screen, only display what I ask it to display.
  • All of the echos are just comments, lines that go off the edge of the screen need to be brought into two lines manually, otherwise word is half on each line.
  • echo. Displayed a blank line.
  • pause > nul accepts any key, but the > nul does not display the prompt so I can put in my own prompt above as an echo comment
  • rmdir removed specified directory (/s removes all subdirectories, files, and directory itself), (/q to suppress prompt) and double quotes ("") to cope with folder name with space in it. The > nul does not display what it is doing.
  • pause asks for confirmation of completion, with default message.
  • del 0% deletes the batch file and %0 is a variable with name of running batch file, so deletes itself no matter what it is called.
If you want any changes, just ask, I am more than happy to help you and make changes. Make sure the directories are correct, and so please read all of the code and make sure you are happy with the comments and functionality.

Richard
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Thanks for that I have saved it as a txt file for now and will change it to a .bat later. I have told my sister how to use it to save her blushes.
 

My Computer

System One

  • Manufacturer/Model
    Lenovo Thinkpad T400
    CPU
    Intel Mobile Core 2 Duo P8700 @ 2.53GHz
    Motherboard
    LENOVO 64734VM
    Memory
    2.00GB Single-Channel DDR3 @ 531MHz
    Graphics Card(s)
    Intel Mobile Intel 4 Series Express Chipset Family
    Sound Card
    Conexant 20561 SmartAudio HD
    Monitor(s) Displays
    15 inch
    Screen Resolution
    1280 x 800
    Hard Drives
    1x 180GB Intel 530 series SSD
    1 x 120GB Hitachi 5400rmp
    1 x 650GB Western Digital Elements 5400rpm
    1x 1Tb Western Digital Elements 5400rpm
    Internet Speed
    Medium for New Zealand
    Other Info
    Weakest part of my computer is the graphics chipset.
    Only ever used a laptop.
    Also use USB Freeview TV Card
    Lenovo Docking Station
    External Speakers
    Other bits a pieces as needed
You are most welcome!
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Thanks for that I have saved it as a txt file for now and will change it to a .bat later. I have told my sister how to use it to save her blushes.

Another approach, if I understand the goal correctly, you can just add the contents of folders you want deleted to CCleaner using Options Include.

Comes in handy for stuff like a browser that's not in the cookies cleaner list, or if you want to clean out the cache etc..

If you want to delete the contents of a folder but not the folder itself just use *.* at the end as in:
c:\folder\*.*


edit: just another way to skin the cat. I was clearing my Chrome cache using the CCleaner method but I found I was killing it too frequently, so I made a separate .cmd batch file to clear the cache when I think of it:

Code:
@echo off
set /p ConfirmVar=Enter Y to Clear Chrome Cache.. 
If %ConfirmVar%==y goto doit
If %ConfirmVar%==Y goto doit
echo Chrome Cache Clear aborted
goto end
:doit
del "C:\Users\Owner\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*"
:end

It's a bit sloppy in that you get 2 confirmation prompts but at least it lets me know it's going to delete the cache. The thing I learned new in this is the "set /p" command for getting user input and assigning it to a variable. I think it's new to Vista/W7.

edit2: btw if you are new to batch files, a good idea is to make a folder and add it to the Path to chuck batch and single .exe files in that don't have any configuration. That way you can open a command prompt and not worry about the default directory. It will find the batch file.

I use C:\Utils and put all kinds of portable apps and batch files in there. If I should do a Custom Windows install, it doesn't get swept up into Windows.old. Usually you just need to make a shortcut to use the programs right away since there's no registry settings. If the program has subfolders or .ini file or whatever, I make a folder and shortcut for it under C:\Utils. After a custom install all my stupid little hotkey tray apps are still there. No reinstall. :)
 

My Computer

System One

  • Manufacturer/Model
    HP Pavilion m9515y
    CPU
    Phenom X4 9850
    Memory
    8 GB
    Graphics Card(s)
    Some Radeon Cheapie with 512 MB Ram
    Monitor(s) Displays
    CRT
    Screen Resolution
    1280x1024
    Hard Drives
    750 GB SATA 3G
    2 SIIG Superspeed docks w/WD Caviar Black Sata II or III
Yeah thanks MilesAhead I only have 2 folders I need her to be able to delete without her looking for them. All sorted now thanks. Niemiro has kindly done that and saved me the trouble of having to learn how to do it.I have Hodgkin's and don't have a lot of time left to learn too much in the way of new stuff.Thanks for the instructions though others will find it useful.
 

My Computer

System One

  • Manufacturer/Model
    Lenovo Thinkpad T400
    CPU
    Intel Mobile Core 2 Duo P8700 @ 2.53GHz
    Motherboard
    LENOVO 64734VM
    Memory
    2.00GB Single-Channel DDR3 @ 531MHz
    Graphics Card(s)
    Intel Mobile Intel 4 Series Express Chipset Family
    Sound Card
    Conexant 20561 SmartAudio HD
    Monitor(s) Displays
    15 inch
    Screen Resolution
    1280 x 800
    Hard Drives
    1x 180GB Intel 530 series SSD
    1 x 120GB Hitachi 5400rmp
    1 x 650GB Western Digital Elements 5400rpm
    1x 1Tb Western Digital Elements 5400rpm
    Internet Speed
    Medium for New Zealand
    Other Info
    Weakest part of my computer is the graphics chipset.
    Only ever used a laptop.
    Also use USB Freeview TV Card
    Lenovo Docking Station
    External Speakers
    Other bits a pieces as needed
Glad you have it set up the way you like. :)
 

My Computer

System One

  • Manufacturer/Model
    HP Pavilion m9515y
    CPU
    Phenom X4 9850
    Memory
    8 GB
    Graphics Card(s)
    Some Radeon Cheapie with 512 MB Ram
    Monitor(s) Displays
    CRT
    Screen Resolution
    1280x1024
    Hard Drives
    750 GB SATA 3G
    2 SIIG Superspeed docks w/WD Caviar Black Sata II or III
hey, I don't know much about bat files but I want to make one that can run in the background so it can be used with full screen apps and use the print screen command then wait an amount of time like 30-60mins then take another print screen and repeat this untill it closers or something, would this be possible?
Thanks
 

My Computer

I would search here:

Free Windows Downloads - Softpedia

Also you can post a request here:

Post New Requests Here - DonationCoder.com

If they know of something that already does it, they'll tell you. If not, and it's not too tough
to program, they'll make it for you. The moderator of that Coding Snacks forum made me a program to total all the play times of media files dropped on it. Check it out.

(Sometimes I program Coding Snacks there too... just truth in advertising so you know I'm a regular on that forum... not trying to be sneaky.) :)
 

My Computer

System One

  • Manufacturer/Model
    HP Pavilion m9515y
    CPU
    Phenom X4 9850
    Memory
    8 GB
    Graphics Card(s)
    Some Radeon Cheapie with 512 MB Ram
    Monitor(s) Displays
    CRT
    Screen Resolution
    1280x1024
    Hard Drives
    750 GB SATA 3G
    2 SIIG Superspeed docks w/WD Caviar Black Sata II or III
Back
Top