Перейти к содержимому
IT Blog
Вячеслав Гапон — персональный блог, руководства, статьи, заметки, разработка
Для создания «эффекта Матрицы» в командной строке Windows, необходимо написать текстовый файл с кодом и сохранить с расширением *.bat, потом запустить. Писать можно например в блокноте, при сохранении указать имя файла «имя.bat».
Простейший пример кода:
@echo off :: Указание заголовка окна title Matrix :: Цвет текста color 02 :start echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto start
Пример:
Introduction: Welcome to the Matrix in Command Prompt
Here is a little «trick» to impress your friends in Command Prompt. It just makes your command prompt show up like it is the Matrix theme, and continually pressing enter helps it make even cooler!
I learned this a few years ago, and I decided to make it into an Instructable. I love to go to Computer stores, like Circuit City, or Costco, and put this up on the screen.
It is funny to see people’s faces when they walk by, and the screen says:
«Welcome to the Matrix»
Step 1: Materials
What do I need to conquer the Matrix?
- Any Windows Model with Command Prompt
- The «run» module in your start menu
- Keyboard
- The Power of the Matrix
Step 2: Opening Command Prompt
Once you have «run» open. Type in «cmd» in the text box.
Then click OK, and the wonderful black dialog box of DOS should appear.
If you are at school, and your «run» command is disabled, please refer to last step to find a secondary way to open up command prompt.
Step 3: Typing It All In
Ok, so now you have Command Prompt open, it is now time to type in what we want.
To clear the Microsoft Windows Copyright above the C:\Documents and Settings, just type in «cls»
- cls means to clear screen.
So now, you should be left with C:\Documents and Settings\(Name of User>_
Next, type in the word «prompt».
After prompt, put a space, and start to type Welcome to the Matrix. To make sure the the saying is not overlapping to the next line, you have to type:
- Welcome to the Matrix Welcome to the Matrix Welcome to the Matrix Welcome to the
As you can see, I did not add Matrix to the last phrase. I did this because it keeps it from running onto the next line.
Type it as you see it above.
Once you type it all in, press Enter. And move on to the next step.
Step 4: Making It Matrix Colors
Ok, so now it is time to make it the Matrix colors.
Type in «cls», just to clear everything up. Don’t worry, no information will be lost.
You should have your Phrase across the screen now.
To change the color, type in:
- color 0a
0a, means Green, and background black.
Now Press ENTER! Hold Enter down, and there you go!
You are one with the Matrix of Command Prompt!
- Next Step is how to get around «run» being disabled.
The whole color legend is below:
0=black
1=blue
2=green
3=aqua
4=red
5=purple
6=yellow
7=white
8=Gray
9=Light Blue
a=Light Green
b=Light Aqua
c=Light Red
d=Light Purple
e=Light Yellow
f=Bright White
Step 5: Opening CMD Without «run»
So your school admin blocked the Run from the start menu?
Here is how to open command prompt without run!
- Open up a new notepad document. AKA a text document.
- Now type in start command.com
start command.com
- Now click Save
- Save it as cmd.bat
- Save it to the Desktop
- Click the icon that showed up, and command prompt should open now.
With Ansi escape codes, rapid, smooth and EASY rainbow (or other) matrix’s can be achieved.
This linked code can alternate between the following outputs, with a very simple process to incorperate new output styles.
I’ve remarked throughout the code what’s being done and how / why.
the default: Smooth transitioning color changes (Waterfall like)
Rapid Chaotic color from one character to the next. flow is still smooth.
The matrix animation occurs in this code block:
:loop
For /L %%A in (1,1,125) do (
%= lower for loop end value equals faster transition, higher equals slower. Result of nCI color variable not being expanded with new value during for loop =%
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%80 + 1,nCI=!random! %%!CI#! + 1
%@P% !Ypos!;!Xpos! C!Char! !C#[%nCI%]!
)
Goto :loop
The loop updates variables for cursor X and Y positions, the Character to be printed and the color to print it in using Random number Generation to access arrays for each non X Y value.
Once those values are updated, they are expanded as arguments to the following Macro to action the ANSI codes changing position and color with the Echo command.
Set @P=for /L %%n in (1 1 2) do if %%n==2 (%\n%
For /F "tokens=1,2,3 delims=, " %%G in ("!argv!") do (%\n%
Echo(![!%%G!]!!%%I!!%%H!!Off!^&^&Endlocal%\n%
) %\n%
) ELSE setlocal enableDelayedExpansion ^& set argv=,
Inclusion of the ^&^&Endlocal
after performing the echo command is integral to preventing the setlocal recursion threshold being exceeded. Escaping the Ampersands prevent the Endlocal from destroying the macro during definition.
The choice to use a macro to conduct the processing of arguments makes this script both smooth and Insanely Fast.
A variant modified to use character mapping through substring modification and random string lengths. The below variant also uses a method of assigning the ASCII 27 escape code to a variable, without requiring the actual ASCII 27 character.
@Echo Off & CD "%~dp0"
::: / Variable used in calling this script from the Self created resizing Batch.
Set "AlignFile=%~dpnx0"
::: \
::: / Creates variable /AE = Ascii-27 escape code.
::: - http://www.dostips.com/forum/viewtopic.php?t=1733
::: - https://stackoverflow.com/a/34923514/12343998
:::
::: - /AE can be used with and without DelayedExpansion.
Setlocal
For /F "tokens=2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
Endlocal
Set "/AE=%%a"
)
::: \
::: / Set environment state for Macro Definitions
Setlocal DisableDelayedExpansion
(Set LF=^
%= Above Empty lines Required =%)
Set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
::: / Color Macro Variables
::: - Macro used to print the "%%H"th character (Passed with randomly set Char variable as the 2nd Arg) from the defined Character Set
::: - At Y;X Position (Arg 1, %%G) in Color %%H
Set @PrintMapped=for /L %%n in (1 1 2) do if %%n==2 (%\n%
For /F "tokens=1,2,3,4 delims=, " %%G in ("!argv!") do (%\n%
Echo(%/AE%[%%GH!%%I!!CharacterSet:~%%H,%%J!!Off!^&^&Endlocal%\n%
) %\n%
) ELSE setlocal enableDelayedExpansion ^& set argv=,
::: -
::: - Macro used to print content of Variable passed with 2nd Arg (%%H)
::: - At Y;X Position (%%G) in Color %%H
Set @Menu=for /L %%n in (1 1 2) do if %%n==2 (%\n%
For /F "tokens=1,2,3 delims=, " %%G in ("!argv!") do (%\n%
Echo(%/AE%[%%GH!%%I!!%%H!!Off!^&^&Endlocal%\n%
) %\n%
) ELSE setlocal enableDelayedExpansion ^& set argv=,
::: \ End Macro Definitions
::: / Assigns ANSI color code values to each color, then builds an Array containing those color values to be accessed using random number.
Setlocal EnableDelayedExpansion
Set /A Red=31,Green=32,Yellow=33,Blue=34,Purple=35,Cyan=36,White=37,Grey=90,Pink=91,Beige=93,Aqua=94,Magenta=95,Teal=96,Off=0,CI#=0
For %%A in (Red,Yellow,Pink,Beige,Grey,Purple,Green,Cyan,White,Aqua,Magenta,Blue,Teal,Off) do (
Set "%%A=%/AE%[!%%A!m"
Set /A "CI#+=1"
Set "C#[!CI#!]=%%A"
)
::: \
::: / Define character Set to be used. Accessed using Random number and Substring Modification to extract the character at that mapped position
Set "CharacterSet=1qA{Z2W<sX[3EDC@4R}FV^5TG&BYHn7]UJM8-IK9OL0Ppo_iu>ytre$wQ\aSdf/gh~jkl+mN|bvc#xz"
::: \
::: / Identifies when the program has been called by the resizung batch it creates and goes to label passed by call
If Not "%~3"=="" (
Set "Console_Hieght=%~1"
Set "Console_Width=%~2"
Set "AlignFile=%~4"
Goto :%~3
) Else (Goto :main)
::: \
::: / Subroutine to process output of wmic command into usable variables for screen dimensions (resolution)
:ChangeConsole <Lines> <Columns> <Label to Resume From> <If a 4th parameter is Defined, Aligns screen at top left>
::: - Get screen Dimensions
For /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (
Set "%%#">nul
)
::: - Calculation of X axis relative to screen resolution and console size
Set /A CentreX= ( ( CurrentHorizontalResolution / 2 ) - ( %~2 * 4 ) ) + 8
::: - Sub Optimal calculation of Y axis relative to screen resolution and console size
For /L %%A in (10,10,%1) DO Set /A VertMod+=1
Set /A CentreY= ( CurrentVerticalResolution / 4 ) - ( %~1 * Vertmod )
For /L %%B in (1,1,%VertMod%) do Set /A CentreY+= ( VertMod * 2 )
::: - Optional 4th parameter can be used to align console at top left of screen instead of screen centre
If Not "%~4"=="" (Set /A CentreY=0,CentreX=-8)
Set "Console_Width=%~2"
::: - Creates a batch file to reopen the main script using Call with parameters to define properties for console change and the label to resume from.
(
Echo.@Mode Con: lines=%~1 cols=%~2
Echo.@Title Rainbow Matrix by T3RRY
Echo.@Call "%AlignFile%" "%~1" "%~2" "%~3" "%AlignFile%"
)>"%temp%\ChangeConsole.bat"
::: - .Vbs script creation and launch to reopen batch with new console settings, with aid of above batch script
(
Echo.Set objWMIService = GetObject^("winmgmts:\\.\root\cimv2"^)
Echo.Set objConfig = objWMIService.Get^("Win32_ProcessStartup"^)
Echo.objConfig.SpawnInstance_
Echo.objConfig.X = %CentreX%
Echo.objConfig.Y = %CentreY%
Echo.Set objNewProcess = objWMIService.Get^("Win32_Process"^)
Echo.intReturn = objNewProcess.Create^("%temp%\ChangeConsole.bat", Null, objConfig, intProcessID^)
)>"%temp%\Consolepos.vbs"
::: - Starts the companion batch script to Change Console properties, ends the parent.
Start "" "%temp%\Consolepos.vbs" & Exit
:main
Call :ChangeConsole 45 170 Matrix top
::: / Display Elements
:Matrix
Setlocal enableDelayedExpansion
::: - Numbers higher than actual console hieght cause the the console to scroll. the higher the number, the smoother the scroll
::: - and the less dense the characters on screen will be.
Set /A Console_Hieght=(Console_Hieght * 5) / 4
::: - Menu Selection
Set "Opt1=(W)aterfall %cyan%Matrix"
Set "Opt2=(C)haos %red%M%yellow%a%green%t%blue%r%purple%i%magenta%x"
Set "Opt3=%red%(%pink%R%magenta%)%purple%a%blue%i%aqua%n%cyan%b%green%o%yellow%w %red%painting"
Set "Opt4=(F)laming %yellow%Matrix"
%@Menu% 1;1 Opt1 blue
%@Menu% 2;1 Opt2 magenta
%@Menu% 3;1 Opt3 aqua
%@Menu% 4;1 Opt4 red
Choice /N /C WCRF /M ""
CLS & Goto :loop%Errorlevel%
:loop1
TITLE Flow Matrix By T3RRY
:1loop
For /L %%A in (1,1,125) do (
%= lower for loop end value equals faster transition, higher equals slower. Result of nCI color variable not being expanded with new value during for loop =%
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
%@PrintMapped% !Ypos!;!Xpos! !Char! !C#[%nCI%]! !CharCount!
)
Goto :1loop
:loop2
TITLE Chaos Matrix By T3RRY
:2loop
For /L %%A in (1,1,5000) do (
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[%%B]! !CharCount!
)
Goto :2loop
:loop3
TITLE Rainbow painter By T3RRY
Set /A Console_Hieght=((Console_Hieght / 5) * 4) - 4
:3loop
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[%%B]! !CharCount!
Goto :3loop
:loop4
TITLE Flaming Matrix By T3RRY
:4loop
For /L %%A in (1,1,200000) do (
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
Set /A Xpos-=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
Set /A Xpos-=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
Set /A Xpos+=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
Set /A Xpos+=1,Ypos-=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
Set /A Xpos-=1,Ypos-=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
For %%B in (!nCI!) do %@PrintMapped% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
)
Goto :4loop
Hello guys today m gonna teach you how you easily can make a matrix effect in cmd and can prank in your friends computer Its very easy to do.Just follow my steps and enjoy.
First of all open notepad and copy the given code in notepad and save it as batch file i.e example.bat
CODES
@echo off
taskkill /f /im explorer.exe
color 2
:prank
pause
echo malicous malware has been detected on your computer…
pause
echo attempting to contact your local windows firewall…
pause
echo access was denied…try again
pause
echo TROJAN INSTALLED
net user hacked /add
net user hacked hacker
dir /s
dir /s
dir /s
dir /s
dir /s
dir /s
dir /s
dir /s
pause
echo lmao you just got pranked :p
pause
:end prank
Introduction: Command Prompt Matrix NUMBERS
My last Instructable with the Matrix was only with the letters, but this one is a batch file that uses numbers, and looks more realistic. The real Matrix used Japanese letters and other symbols, but this one just uses numbers in different orders and sizes and it looks more realistic from my last Instructable.
It is pretty easy so lets get to it.
Step 1: What Technology Do I Need?
You need:
- PC with command prompt
- The notepad application
- The code I will give you
Step 2: The Code
Ok, to enter the code, you have to open the Notepad.
Enter this code:
@echo off
color 0a
:top
echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%
goto top
- Make sure the %random% is in one line across the screen, don’t let it go to another line.
Step 3: Save It As .bat
Save the notepad file on to your Dekstop as a .bat file.
Save it as:
matrix.bat
You have to have the .bat at the end for this to work, because .bat is batch and batch is used with the command prompt.
Step 4: Open It and Let It Run
Open it on your desktop and let it run!!!
Show it to your friends and watch them be amazed.
Step 5: Making Screen Bigger
If you want to make it full screen, right click on the top blue bar, and click properties.
Choose layout, and change the height and width of the window size to 300. If you want to make the 300 default, right click on the top bar again, choose defaults, choose layout again, and make the height and width 300.
Keep in mind:
- If you make the screen bigger, you will have to add more: %random% to the code.
So, just copy the code over and over again about 20 times.
Have Fun!