Repeat a cmd command

3ssio Posted messages 83 Status Membre -  
3ssio Posted messages 83 Status Membre -

Hello, I have a question, I would like to create a stylish wallpaper on CMD but I have a problem.

I type (color a) then (dir/s) but the problem is that after a while it stops and I would like it to continue looping indefinitely.

If anyone has an idea or knows how to do it, thank you

Thank you in advance for your responses

Good evening


6 réponses

fabul Posted messages 42093 Registration date   Status Modérateur Last intervention   6 032
 

Hello,

:begin

goto begin

0
3ssio Posted messages 83 Status Membre 1
 

Unfortunately, it doesn't work for me

thank you anyway

0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098 > 3ssio Posted messages 83 Status Membre
 

Hello,

There are different ways to create an infinite loop in a batch file, including the one that was mentioned, and we don't see why it wouldn't work:
https://stackoverflow.com/questions/5487473/how-to-create-an-infinite-loop-in-windows-batch-file

We don't really see the point of looping a DIR command whether it's colored or not (there are also other ways to color all or part of the console), but if you don't publish your exact code, it will be hard to discuss "it's not working" without further details.

0
3ssio Posted messages 83 Status Membre 1
 

I want to loop the dir/s command to create a wallpaper, I'm useless and don't know anything about coding

My code: color a

dir/s

but I can't figure out how to loop it

Thanks


0
jee pee Posted messages 31913 Registration date   Status Modérateur Last intervention   9 947
 

Hello,

Once upon a time, jokes were made about PCs with

@echo off title matrix color 0a :top echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top

you can do the same with your code

@echo off title Loop color a :top dir/s goto top 

0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098
 

Hello,

Houston, we have a problem: Fabul responded, me too, now you, I asked in <3> to see the script so that the same request could be repeated in <4> without, and yet, just in case, even though it's unlikely, I tested it and it works...

1
jee pee Posted messages 31913 Registration date   Status Modérateur Last intervention   9 947 > brucine Posted messages 24394 Registration date   Status Membre Last intervention  
 

Yes, but if we don't have, like all of us, the tech-savvy fiber, we can write:

color a dir/s :begin goto begin

especially if we type it each time in a CMD window, not with a batch file.

0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098 > jee pee Posted messages 31913 Registration date   Status Modérateur Last intervention  
 

No, you need to put dir /s after the label :begin.

I'm not sure that branching instructions are only read in a batch file and not at the command line, that's another question.

0
jee pee Posted messages 31913 Registration date   Status Modérateur Last intervention   9 947 > brucine Posted messages 24394 Registration date   Status Membre Last intervention  
 

Yes, of course, it was an example of code to illustrate an error that someone with little experience might write if they are not given the complete code.

0
3ssio Posted messages 83 Status Membre 1
 

I don't know why it's not working.

I think I understood that when I run the dir/s command, it happens instantly, so I can't execute the others.

I believe I'm doing it wrong.

Yes, I truly suck.

Thank you for your responses.


0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098
 

Because, again, you cannot loop at the command line; your command sequence must be in a batch file cmd (new text saved as toto.cmd).

0
quentin2121 Posted messages 9063 Registration date   Status Membre Last intervention   1 311 > brucine Posted messages 24394 Registration date   Status Membre Last intervention  
 

Hello!

It works for me, I can color the console well, but our friend Ssio wants to color his screen, what adjustment to the command then?

0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098 > quentin2121 Posted messages 9063 Registration date   Status Membre Last intervention  
 

Hello,

We're mixing genres.

The DIR command will not concern the wallpaper but only the console; we don't see the point of repeating it, but if we have to do it not in a batch but directly in the command line, the redirection labels will not be read, we should use something like:

FOR /L %A IN (0,0,1) DO ( DIR /S )

There are different ways to color all or part of the console: the color command (which can be refined by also setting a background color), just the prompt, highlighting text only by echoing ANSI characters, third-party utilities...

But if I want to change my Windows wallpaper, it's independent of such a DOS command, I must create or use a 24-bit bmp image and use, I haven't tested not in a batch but at the command line:

reg add "HKCU\Control Panel\Desktop" /v Wallpaper /d "C:\Path_to_image" /F RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True


1
quentin2121 Posted messages 9063 Registration date   Status Membre Last intervention   1 311 > brucine Posted messages 24394 Registration date   Status Membre Last intervention  
 

The first command triggers nothing

The second one does not become .cmd with the gear wheel as the thumbnail icon!

0
brucine Posted messages 24394 Registration date   Status Membre Last intervention   4 098 > quentin2121 Posted messages 9063 Registration date   Status Membre Last intervention  
 

Any command aimed at the registry executes silently (that's actually the danger).

I don't understand your second comment at all (even if I input an incorrect syntax in a cmd file, the batch won't execute, but it will remain a cmd file with its icon); there's no question of executing the two lines separately although maybe we can, they're in a Batch (new text file saved as toto.cmd).

It's worth noting that the image used must be a 24-bit bmp (and adapted to the screen resolution), which is one of the quirks of Windows since it will be immediately converted to jpg and stored in a designated location.

Not many people have bmps on hand, save a jpg as a 24-bit bmp using the graphic software of your choice.

0
jee pee Posted messages 31913 Registration date   Status Modérateur Last intervention   9 947
 

To do this across the entire screen, open a command line window, switch to full screen: ALT + Enter, then launch the .cmd file


0
3ssio Posted messages 83 Status Membre 1
 

Thank you all for your responses

I finally managed to do it thanks to you

Thank you!


0