IF statment GTR

Toshiba Satellite l505d-s5965 notebook
April 4, 2010 at 07:51:45
Specs: Windows 7, 1024
having issues

cant figure out how to get the number of input from a variable.
set input =test
set /p input=ask for input

like IF input GTR 3 echo number of times are up.

but if input is right goto this

just want to test for the max of 3 tries then if it fail in 3 tries echo MSG, but if got right with in 3 move along.

thanks guys!


See More: IF statment GTR

Report •


#1
April 4, 2010 at 08:02:05
if input lss 4 goto :ok
or
if input leq 3 goto :ok
or
if input gtr 3 goto :notok
look at output from:
if /?
to see the options

Report •

#2
April 4, 2010 at 12:00:22
ok i have a file with a word that has to be guessed.

i use
set /p guess=guess word?

i then use FINDSTR because the word is in a txt file

and use the errorlevel 1 if fail
echo failed.

but how would i go about counting the tries with the FINDSTR in the file?


Report •

#3
April 4, 2010 at 12:52:20
@echo off & setlocal EnableDelayedExpansion

for /L %%j in (1 1 3) do (
  set guess=
  set /P guess=guess word? 
  find /I "!guess!" myfile.txt > nul && goto :FOUND
)
echo.  FAILED
goto :EOF

:FOUND
echo,  "%guess%" FOUND


Report •

Related Solutions

#4
April 4, 2010 at 13:08:29
thanks IVO,


i edited your code a little, think you can make something of it?

@echo off & setlocal EnableDelayedExpansion

for /L %%j in (1 1 3) do (
set choice=
>$$$.vbs echo wsh.echo inputbox("Enter Unlock Password!")

for /f "tokens=*" %%a in ('cscript//nologo $$$.vbs') do set Choice=%%a

find /I "!Choice!" C:\Locker\Password > nul && goto :FOUND
)

>$$$.vbs echo wscript.quit msgbox("%choice% Password Doesn't Match")
cscript//nologo $$$.vbs


goto lock

:FOUND

ATTRIB -s -h C:\Locker

>$$$.vbs echo wscript.quit msgbox("Unlocked!")
cscript//nologo $$$.vbs


thank you
Brock


Report •

#5
April 5, 2010 at 04:22:16
edit 123

Report •

#6
April 5, 2010 at 10:22:07
A general rule is to never mix two scripting languages, as anyone who debugs your script must know all of the languages well enough to debug which language holds the bug.
Change
>$$$.vbs echo wsh.echo inputbox("Enter Unlock Password!")
to
>$$$.vbs echo wsh.echo inputbox("Enter Unlock Password!"^)


Report •


Ask Question