logo elektroda
logo elektroda
X
logo elektroda

Creating MATRIX Script with Nested Loops for Infinite Green Numbers Animation in CMD

Eufor 102831 17
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 9615708
    Eufor
    Level 17  
    I wrote a short script called MATRIX, i.e. a loop of green numbers flying from top to bottom in the command line window:
    @echo off
    title MATRIX
    color a
    :start
    echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%
    goto start

    It is very easy to write, but the braiding itself already has a loop that makes it repeat the echo% random% command.
    And I would need a second loop whose task would be to repeat the same running of the application indefinitely ... :)
    I have tried several ways but nothing works because the loop that is already entered in the code is in the way, does anyone know how to enter this command correctly?

    I say right away that I do not do it for some damage to other network users, but for the purpose of securing my own computer against prying eyes;]

    I forgot to add this loop is:
    :start
    tutaj jakieś wartości
    goto start


    Added after 1 [hours] 30 [minutes]:

    One more question about the batch ...
    I wrote two short scripts, the one above and one similar, and I wrote a third one that performs the task of running the above two at once with one shortcut only now I have a problem I would like these scripts to run in full screen mode, so I created shortcuts and selected the full option in them Unfortunately, everything works only when I run it manually and when I run it my script runs in windowed mode; / Of course my script runs shortcuts to the application data, not the same.
    Anyone know how to fix it?
    Quite urgent ...

    Okay, somehow I managed:
    @echo off
    cd\
    cd Documents and Settings\xp\Pulpit
    start matrix2
    title MATRIX
    color a
    :start
    echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%
    goto start


    This script is designed to pretend to be the matrix and turn itself on forever :D
    But I still have a problem with this full-screen mode, will anyone help? ; d
  • ADVERTISEMENT
  • #2 9616370
    GrivIN
    Level 11  
    Right button on the bat file, properties, display tab and there is "Run full screen" somewhere. if necessary, to switch the program to full screen / window use ALT + Enter combination
  • #3 9616459
    Eufor
    Level 17  
    Yes, I know about it, but I mean that when the application starts automatically, i.e. it calls itself without interruption, in full screen mode there is only the first window that I start manually and the rest is in the window, come running the same as me manually :(

    Maybe it will simplify a bit because it is quite complicated ...
    Suppose we have a matrix.bat file whose task is to show the text: matrix and turn itself on again, when it turns on it does it again and again ..
    However, when I turn it on manually for the first time it starts in full screen and when it does it by itself and starts itself again and again, it is already in windowed mode, why?
  • ADVERTISEMENT
  • #4 9617872
    iagre
    Level 35  
    Show all these scripts and we'll know how to go about it.
  • Helpful post
    #5 9618305
    marek003
    Level 40  
    Everything is good only ...
    wrench the whip start for a moment, that is
    "rem start matrix"
    Run the file [in the window]
    right click on the title bar of the window and select the option according to the photo below.

    Creating MATRIX Script with Nested Loops for Infinite Green Numbers Animation in CMD

    Disable the script operation.

    Edit and restore the start matrix.

    Restart and ... they all work in full screen (alt + tab switching opens another screen, not a matrix window.

    In my case, I have the option to open 250 files in the confignt options. Enabling this script is a huge burden on the processor, not to mention the dramatic slowing down of "flying" numbers. (By the way, in the matrix, the stamps flew from top to bottom, not to the side, but ...) I would like to add that the numbers when so many files are open appear only after a minute or so. Earlier black screen before the computer decides to show something.

    As for me, I don't see the point in opening more windows with the same task, but people's desires are unexplored :)

    I would like to mention for less experienced ones that when they get bored of looking at numbers, they would press alt + space or ctrl + break and then through the task manager (Ctrl + alt + del) they would remove working scripts in groups.
  • #6 9619275
    Eufor
    Level 17  
    marek003 Thanks, that's what I meant;]

    Added after 5 [minutes]:

    But following the blow ...
    Yes, I know running myself endlessly muddies the computer and with about 30 files open, you can not see anything anymore, only a black screen.
    So how do we impose a command so that the loop repeats its command e.g. only 10 times?
  • Helpful post
    #7 9620410
    marek003
    Level 40  
    Try this:

    @echo off 
    break on
    
    title MATRIX 
    color a 
    
    if "%1" == "" FOR %%A IN (1 2 3 4 5 6 7 8 9) DO start C:\Docume~1\xp\Pulpit\matrix.bat %%A
    
    :petla 
    echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% 
    goto petla


    It's a bit perverse. The FOR loop will execute when matrix has no parameter (i.e. for the first time). The loop runs the matrix file with the loop count parameter each time it rotates, so subsequent matrix runs do not trigger the loop. Equally, instead of %% A, there can be any number or letter, e.g.

    if "%1" == "" FOR %%A IN (1 2 3 4 5 6 7 8 9) DO start C:\Docume~1\xp\Pulpit\matrix.bat 1


    With a full screen on a 2.4GHz and 2Gb pentium 4, the digits appear on the screen after about 10 seconds.
  • #8 9620997
    Eufor
    Level 17  
    Once again, thanks a lot;] It works, but with the second command;]
  • ADVERTISEMENT
  • #9 9621738
    WojtasJD
    Level 43  
    marek003 wrote:
    "rem start matrix"
    Run the file [in the window]
    right click on the title bar of the window and select the option according to the photo below.
    [...]

    A side effect of this is that all windows "C: \ WINDOWS \ system32 \ cmd.exe" are opened to the full screen and only those with a title specified in .bat (eg "MATRIX") are allowed.


    Another version :wink: without referencing the .bat file
    FOR /L %%a IN (1,1,10) DO start "MATRIX RELOADED" cmd /V:ON /Q /T:0A /K "for /l %%b in (0,0,0) do echo !random! !random! !random! !random! !random! !random! !random! !random! !random! !random! !random! !random! !random! !random!


    It would be useful to figure out where the echo command is, which unfortunately adds newlines to the numbers.
  • #10 9633992
    Eufor
    Level 17  
    @echo off
    color 9f
    title Nowe konto admina
    net user Matrix matrix /add
    net localgroup administratorzy /add Matrix
    pause
    echo Konto Matrix (administrator) zostało dodane! Hasło: matrix
    @echo on
    pause
    exit


    Now something like that :) But I would like this text: Matrix (administrator) account added! Password: matrix
    It was only displayed if the previous net * commands were successful :) I've been trying a bit, but somehow I can't apply it; /
  • #11 9634006
    Atreyu Makiavel
    Level 34  
    If the previous commands return any error codes then you can use if.
  • #12 9634059
    WojtasJD
    Level 43  
    net user Matrix matrix /add && net localgroup Administratorzy /add Matrix && echo Konto Matrix (administrator) zostało dodane! Hasło: matrix


    command1 && command2 && ... - command2 will be executed if command1 is successful ...

    edit:
    to 'mute' commands (we don't want any error messages on the screen):

    net user Matrix matrix /add > nul 2>&1 && net localgroup Administratorzy /add Matrix > nul 2>&1 && echo Konto Matrix (administrator) zostało dodane! Hasło: matrix
  • #14 9635510
    Eufor
    Level 17  
    Okay, if the net * commands are done well, it displays the text that it's okay :)
    And can you add a second text to it that will be displayed when an error occurs? :)
  • ADVERTISEMENT
  • #15 9637730
    Eufor
    Level 17  
    I mean something similar to the "if" function in exel :)
  • #16 9637792
    Atreyu Makiavel
    Level 34  
    Eufor wrote:
    I mean something similar to the "if" function in exel
    So a plain "if".
  • Helpful post
    #17 9637856
    WojtasJD
    Level 43  
    You can combine with if, and more simply:
    net user Matrix matrix /add > nul 2>&1 && net localgroup Administratorzy /add Matrix > nul 2>&1 && echo Konto Matrix (administrator) zostało dodane! Hasło: matrix || echo Wystapil jakis blad
  • #18 9637888
    Eufor
    Level 17  
    Thanks a lot WojatasJD, you are one of the few who give details :)

Topic summary

The discussion revolves around creating a CMD script named MATRIX that generates an animation of green numbers falling in a loop. The user seeks assistance in implementing a nested loop to allow the script to restart indefinitely while maintaining full-screen mode. Various solutions are proposed, including using a FOR loop to manage the script's execution and parameters to control the number of iterations. Users also discuss the performance impact of running multiple instances of the script and suggest methods to limit the number of loops. Additionally, there are inquiries about error handling in batch commands, specifically how to display messages based on the success or failure of commands executed within the script.
Summary generated by the language model.
ADVERTISEMENT