Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Solved: Quick and Simple IF with OR question

Reply  
Thread Tools
scrfix's Avatar
Computer Specs
Member with 337 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
14-Nov-2009, 11:21 PM #1
Solved: Quick and Simple IF with OR question
Is it possible to have a statement such as
If /i %variable% == "this" OR "that" OR "this"

Example:
If /i %_OS% == XP (
set _regfolder=shell folders
Goto _CheckMyDocPath
)

If /i %_OS% == Vista (
set _regfolder=shell folders
Goto _CheckMyDocPath
)

If /i %_OS% == 7 (
set _regfolder=shell folders
Goto _CheckMyDocPath
)

Can I combine those into one IF statement. Everything I find shows me one answer per IF statement. Is it possible to combine them or do I have to use a FOR statement for it?

Thanks,
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets
Resources LLC: Water Treatment Coagulation, Water Recycling
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
15-Nov-2009, 04:00 AM #2
Easiest to just use three statements for an OR type check.

I would write those this way though:
Code:
set _regfolder=shell folders
If /i %_OS% == XP Goto _CheckMyDocPath
If /i %_OS% == Vista Goto _CheckMyDocPath
If /i %_OS% == 7 Goto _CheckMyDocPath
Set _regfolder=value for other os
You can also use a For loop
Code:
For %%I In ("XP","Vista","7") Do If /i %_OS%==%%~I (set _regfolder=shell folders)&Goto _CheckMyDocPath
:: We get here only if not XP, Vista, or 7
Haven't forgotten about the scheduled task issue, just haven't made the time to dig into it further yet.
scrfix's Avatar
Computer Specs
Member with 337 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
15-Nov-2009, 04:35 AM #3
Ok, so I do have to utilize a FOR statement for this. I figured that was the case. That is a pretty simple OR statement. Kind of sucks that you cannot just use IF %this% == "this" || "this" || "even this" GOTO Wherever.

Thanks for the FOR statement. Yes, I am still working on the scheduled tasks as well. I did not test your code from last week yet. I don't know that I will have a chance to test it this weekend or not. It may have to wait until next weekend. This time of the year I am slammed busy.
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets
Resources LLC: Water Treatment Coagulation, Water Recycling
ghostdog74's Avatar
Member with 146 posts.
 
Join Date: Dec 2005
15-Nov-2009, 10:34 AM #4
Quote:
Originally Posted by scrfix View Post
Kind of sucks that you cannot just use IF %this% == "this" || "this" || "even this" GOTO Wherever.
many other good programming languages (including vbscript) supports this syntax, but not batch. if you think that it sucks, then switch to a better one.
scrfix's Avatar
Computer Specs
Member with 337 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
15-Nov-2009, 11:15 AM #5
Ghostdog,

You are too funny. You have been trying to get me to switch for quite some time now... lol

I think we have had this discussion before. I do plan on learning VBScript as well as batch. When I am as good as Jerry and Squashman on batch files, I feel I can learn no more because I have a good grasp and understand everything I am looking at to the point I can troubleshoot and pinpoint issues on my own without having to ask and I can only provide help to people then I will switch over to VBScript and start learning that.



I feel that I am heading that direction because I am no longer asking 5000 questions a day.
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets
Resources LLC: Water Treatment Coagulation, Water Recycling
ghostdog74's Avatar
Member with 146 posts.
 
Join Date: Dec 2005
15-Nov-2009, 11:34 AM #6
Quote:
Originally Posted by scrfix View Post
Ghostdog,
You are too funny. You have been trying to get me to switch for quite some time now... lol
:
whether you want to switch or not, is not my problem. I am just stating facts for you about the if construct, that;s all.

Last edited by ghostdog74; 15-Nov-2009 at 11:44 AM..
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:59 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.