3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Advanced Batch

Step 7IF Command - But I'm Greater Than You (2/2)

IF Command - But I\
Ok, so you've got a nice IF statement and all, and checking whether variables are equal or not is nice and all, but doesn't quite fit the bill. I want something to happen if variable1 is less than the other variable!

For those of us programmers, I know this seems like a simple task. Just do what all the other programming languages do!

Well hold your horses cowboy. Not so fast. A Batch file isn't just your regular ol' programming langage. Silly as it may seem, the "<" and ">" don't work with Batch files.
EQU - Equal - ==NEQ - Not EqualLSS - Less ThanGTR - Greater ThanLEQ - Less Than or Equal ToGEQ - Greater Than or Equal To
Just put these operands in place of the ==

Example:
IF 32 GTR 3 ECHO This Will Work
@ECHO OFFIF 32 GEQ 32 (ECHO 32 is Greater Than, or Equal to 32) ELSE (ECHO 32 is definitely Equal to 32)PAUSEIF 32 LSS 32 (ECHO 32 is Less Than 32? I think not.) ELSE (ECHO 32 is Not Less Than 32. End of story.)PAUSE
« Previous StepDownload PDFView All StepsNext Step »
5 comments
Jul 10, 2008. 12:52 PMEvilthingamabober says:
@echo off
color 29
Echo Chose the right number or get PWNED!
SET /p doom1=
SET boom2=8
IF %doom1%NEQ%boom2% (
start http:/www.epicwinrar.com/
)
I tried this batch out but it didn't work. What did I do wrong?
Jul 16, 2010. 11:54 AMteh_pwnage says:
@ECHO OFF color 29 :hmm? Echo Chose the right number or get PWNED! echo. echo. set /p lol=Choose or ELSE!!!))) if %lol%== 8 good... if not %lol%== 8 goto pwn :pwn start http://www.youtube.com/watch?v=oHg5SJYRHA0&feature=related/ exit :good... echo You got lucky... pause >nul
Jun 25, 2009. 9:14 AMwill421 says:
EKKKK!!! Rick roll!
Jul 16, 2010. 11:54 AMteh_pwnage says:
@ECHO OFF color 29 :hmm? Echo Chose the right number or get PWNED! echo. echo. set /p lol=Choose or ELSE!!!))) if %lol%== 8 good... if not %lol%== 8 goto pwn :pwn start http://www.youtube.com/watch?v=oHg5SJYRHA0&feature=related/ exit :good... echo You got lucky... pause >nul
Jul 11, 2008. 5:40 PMEvilthingamabober says:
Thanks. Time to own my parents...
Feb 4, 2008. 6:32 PMGrimesFace says:
Are there any other applications of this other than math? I mean, I'm sure there is, but I can't think of anything. Just started learning from your tutorials, btw. Having great fun :)
Mar 27, 2008. 7:54 AMlordoftrek says:
I use batch files scheduled to run at specific times using Task Scheduler to automate my home server. It logs its activities, defragments drives, shuts down, backs itself up, and updates a website all by itself. I've found out its just fun to see what you can get them to do. You can use any command you can type at the command prompt in a batch file. Combining them with IF statements and FOR loops lets you write some pretty powerful programs just using batch files.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
22
Followers
5
Author:Neodudeman