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:
How it works (line by line):
echo Converting computer to new user...
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 Press any key to begin:
pause > nul
rmdir /s /q C:\Users\username\Videos\R18\ > nul
rmdir /s /q C:\Users\username\Pictures\"Slide Shows"\ > nul
- @ 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.