So I was browsing through YouTube when I stumbled upon this comment in one of FlyTech’s self-made Windows easter eggs videos:

I think I might have discovered a real easter egg.

If you type “cmd | cmd” into a command prompt, you get a “glitched” command prompt, where every “block” of output (line by line) is ran as a new command, until it reaches the end of the block. For example, if you typed “echo Hello World”, it would echo “Hello World”, after that, attempting to run “Hello World” as a command. However, for some reason if the output doesn’t include backslashes then it will say “Access is denied” instead of what would actually come up if you typed “Hello World” into the prompt (it would tell you it’s not a valid file/directory/program/batch script, obviously).

Anyways, that’s not the easter egg itself. If you type “exit” into this “glitched” prompt, not only will it exit, but before that, it will display an output saying “More?”. I believe this occurs if you attempt to run commands after the prompt should have exited. I haven’t the foggiest idea on how piping exactly works, though, that’s just my theory on why the easter egg occurs if you do this.

If you don’t know who FlyTech is, go check out his channel on YouTube! He makes Windows experiment videos which are very fun to watch if you wanna learn more about Windows.

Anyways, here’s the shortened version: If you type cmd|cmd into a Windows command prompt, you get a glitched version of the command prompt. In this version every line of output is ran as a new command. If you type exit, it prints More? before exiting into the regular command prompt. Although this user says it’s an easter egg, by the looks of it, it’s definitely not.
I’ve made a one-line command you can run in a Command Prompt and the Run (Win + R) box (it even has a convinient message when you exit):

cmd /c cmd|cmd&echo ----------------------------&echo Exited from cursed Command Prompt.&echo Press any key to exit...&pause>nul

Investigating the bug

Currently why this works in the first place is hard to know, as the Command Prompt needs a /c or /k before running.
Interestingly, I did try cmd|cmd /c. At first there was nothing. But when pressing Enter it prints The process tried to write to a nonexistent pipe., and it does that every time you press Enter. Interestingly, pressing Ctrl + C/Ctrl + Break prints the string thrice, and eventually it will return to the normal Command Prompt. Typing any command in only prints the same string thrice again. Typing exit works, though.
cmd|cmd /k has the same effect as cmd|cmd, but there’s no copyright and version text displayed.

Checking the claims

First, this commenter says that typing echo Hello World would print Hello World, and then attempt to run it as a command. But they also say that if the output doesn’t include backslashes then it’ll say Access is denied. instead of the usual '<name>' is not recognized as an internal or external command, operable program or batch file.

Now, Access is denied or error 5, happens when a command or an operation requires elevation (administrator privileges). But Hello World doesn’t require elevation to run as a command, so what’s happening here?

Turns out: It’s not running Hello World as a command, it’s actually running the prompt itself as a command! For example, if I run echo Hello world in C:\test, it’ll run the prompt itself plus the command’s output as a command, so it’s running the command C:\test>Hello world. The greater than sign means “execute the command specified before the sign, then save the output into the file with the name specified after the sign”.
I managed to prove this by writing a batch script named test.bat in my testing folder, creating a folder named test in the same folder, cding into the test folder, then running echo test.txt. Indeed, now there’s a file named test.txt in the test folder with the expected output of the test.bat script in the parent directory.

Next, the More? output upon exiting. I did some research and found out that the More? message is literally the effect of a backslash in Python, but it’s a caret (^) and not a backslash. I have no idea why that message appeared, but the normal prompt is right under the More?, which is not supposed to happen, there should be a blank line between the two lines. But the cause is actually because the first newline is printed right next to the More? message. It’s even more obvious if you run my one-line command above.


<
Previous Post
How I Talk in Discord
>
Next Post
Disabling Windows Defender the EFFICIENT way