Step-by-Step Guide
1. Open Notepad
- First, open Notepad on your Windows computer. You can do this by searching for "Notepad" in the Start menu or by pressing `Win + R`, typing `notepad`, and hitting `Enter`.
2. Write the Start Command
- In Notepad, type the following command:
```
start
```
- This command, when executed, will open a new CMD window.
3. Save the File as a ".bat" File
- Save the file with a `.bat` extension. To do this, click on `File` > `Save As`, then in the "Save as type" dropdown, select `All Files`. Name your file something like `open_cmd.bat` and save it.
4. Understanding the Start Command
- When you double-click this `.bat` file, a single CMD window will open. If you write the `start` command twice in the Notepad file:
```
start
start
```
- It will open two CMD windows. Similarly, if you write it ten times, it will open ten CMD windows.
(After changing anything in the notepad ".txt" file, click save. If not changes will not be made to the ".bat" file)
Creating an Infinite Loop
Now, let’s take it a step further. What happens if you put the `start` command in a loop? This is where things get interesting (and potentially chaotic).
1. Write a Loop in Notepad
- Here’s how you can create an infinite loop:
```
:loop
start
goto loop
```
- This script creates a label `:loop`, starts a CMD window, and then goes back to the `:loop` label, repeating infinitely.
2. Save and Run the Loop Script
- Save this file as `loop_cmd.bat` using the same method described earlier.
- Warning: Running this file will cause your computer to open an infinite number of CMD windows, which will likely freeze your computer. This is purely for educational purposes to understand batch scripting and should not be executed without caution.
Conclusion
When you double-click on `loop_cmd.bat`, it will open infinite CMD windows, leading to a system freeze. However, it’s essential to know that this script is harmless in terms of data integrity—it won’t steal or delete any data from your computer. It’s just a fun and simple demonstration of batch scripting.
Coding, at its core, is about giving precise instructions to a computer. Computers will execute any command, no matter how silly or complex, exactly as they are told.
Final Note
Remember, with great power comes great responsibility. Batch scripting is a powerful tool, so use it wisely. If you found this tutorial helpful and want to learn more about tech and coding, follow me for more tips and tricks to level up your tech skills!


0 Comments
Post a Comment