Computing.Net > Forums > Programming > Batch File If contains

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File If contains

Reply to Message Icon

Name: jcgun
Date: April 28, 2009 at 13:53:29 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

Hello,
I want the user of my Batch File to type in a sentence, and if it contains a 'keyword' i want them to be directed to a section of the batch file.

Thing is, I'm currently using:
if '%input%'=='keyword' goto keyword
and at the bottom i have (to be sure):
goto %input%

Using this, the keyword has to be at the beginning of the sentence.

So, if the keyword is 'made', then i would work if the user typed 'made', but not if they typed 'who made you'.

Is there a way for the keyword to be anywhere in the sentence?



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: April 28, 2009 at 14:04:35 Pacific
Reply:

if not "%input:keyword=%"=="%input%" goto keyword


0

Response Number 2
Name: jcgun
Date: April 29, 2009 at 11:19:09 Pacific
Reply:

BRILLIANT!! Thanks

is there a way to have two keywords, both required to access


0

Response Number 3
Name: Judago
Date: April 29, 2009 at 13:58:59 Pacific
Reply:

if not "%input:keyword1=%"=="%input%" (
if not "%input:keyword2=%"=="%input%" goto keyword
)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File If contains

Batch file, if filename exists www.computing.net/answers/programming/batch-file-if-filename-exists/17368.html

batch file if help www.computing.net/answers/programming/batch-file-if-help/18225.html

Replace text through batch file www.computing.net/answers/programming/replace-text-through-batch-file/20140.html