windowsbatch-filedelete-filenotepad

What does this Notepad (.bat) code do and how does it work?


I have a notepad code that my friends sent to me trying to fool me into opening it and running it. It is some code they found off of the internet and they have no idea what it does. Here it is:

@echo off
Del C:\ *.* |y

Can someone please explain to me what this does? It would be greatly appreciated.


Solution

  • .Bat files are also known as Batch files.

    As @foxidrive pointed out, this example will result in

    'y' is not recognized as an internal or external command, operable program or batch file.
    

    Basically it is a file that contains runnable script on your computer, often used for automating some routines.

    Now what your script does.

    @echo off - turn off the output, often used on top of the script files.

    Del C:\ *.* |y - Delete all files in directory "C:\", and confirm any popup.

    This script is very dangerous, but it's not as harmful as if you run it as Administrator. At that point it would delete a lot of System files (Not all of them, it would not delete any running file or file owned by System user or TrustedInstaller), but really, do not try running it on your computer.