Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 436 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch script loop

#11
You could also try this instead of a `for` loop:

set count=0
:loop
set /a count=%count%+1
(Commands here)
if %count% neq 100 goto loop
(Commands after loop)

It's quite small and it's what I use all the time.
Reply

#12
Very basic way to implement looping in cmd programming using labels

@echo off
SET /A "index=1"
SET /A "count=5"
:while
if %index% leq %count% (
echo The value of index is %index%
SET /A "index=index + 1"
goto :while
)

Reply

#13
The answer really depends on how familiar you are with batch, if you are not so experienced, I would recommend incrementing a loop variable:

@echo off
set /a loop=1
:repeat
echo Hello World!
set /a loop=%loop%+1
if %loop%==<no. of times to repeat> (
goto escapedfromrepeat
)
goto repeat
:escapedfromrepeat
echo You have come out of the loop
pause

But if you are more experienced with batch, I would recommend the more practical `for /l %loop in (1, 1, 10) do echo %loop` is the better choice.

(start at 1, go up in 1's, end at 10)
for /l %[your choice] (start, step, end) do [command of your choice]
Reply

#14
I have 2 answers
Methods 1:
**Insert Javascript into Batch**

@if (@a==@b) @end /*

:: batch portion

@ECHO OFF

cscript /e:jscript "%~f0"


:: JScript portion */

Input Javascript here
( I don't know much about JavaScript )

Method 2:
**Loop in Batch**

@echo off
set loopcount=5
:loop
echo Hello World!
set /a loopcount=loopcount-1
if %loopcount%==0 goto exitloop
goto loop
:exitloop
pause

(Thanks FluorescentGreen5)
Reply

#15
a completely flawless loop

set num=0
:loop
:: insert code
set /a num=%num%+1
if %num% neq 10 goto loop
::insert after code code
you can edit it by changing the 10 in line 5 to any number to represent how many time you want it to loop.
Reply

#16
`for /l` is your friend:

for /l %x in (1, 1, 100) do echo %x

Starts at 1, steps by one, and finishes at 100.

**WARNING:** Use `%%` instead of `%`, if it's in a batch file, like:

for /l %%x in (1, 1, 100) do echo %%x

>(which is one of the things I really really hate about windows scripting.)

If you have multiple commands for each iteration of the loop, do this:


for /l %x in (1, 1, 100) do (
echo %x
copy %x.txt z:\whatever\etc
)

or in a batch file

for /l %%x in (1, 1, 100) do (
echo %%x
copy %%x.txt z:\whatever\etc
)

Key:
`/l` denotes that the `for` command will operate in a numerical fashion, rather than operating on a set of files
`%x` is the loops variable
(starting value, increment of value, end condition[inclusive] )
Reply

#17
Use `FOR /l` and make sure to use `%%` instead of `%`
It will save you headaches.

And try to Set the loop.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through