Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Need help with ELSE IF in dos

  • Please log in to reply
2 replies to this topic

#1 KrimsonSkies


  • Members
  • 2 posts
  • Local time:11:27 AM

Posted 12 January 2015 - 04:26 PM

Below is the c++ version of how I want my batch file to operate:


if(var == 1)

     do something

else if(var == 2)

     do something else


     do nothing



As far as I know, there is not an ELSE IF for dos.

How can I get around this?

BC AdBot (Login to Remove)


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Malware Response Team
  • 12,304 posts
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:27 AM

Posted 12 January 2015 - 07:14 PM

else if is equivalent to putting another if inside of an else. So you can do something like

if (var == 1)
    do something
else (
    if (var == 2)
        do something else
        do a third thing
(I don't remember the syntax for putting multiple statements into an if or similar in batch scripts but nonetheless this pattern works in all languages)


Edited by Billy O'Neal, 12 January 2015 - 07:15 PM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 JohnnyJammer


  • Members
  • 1,117 posts
  • Gender:Male
  • Location:QLD Australia
  • Local time:02:27 AM

Posted 12 January 2015 - 11:17 PM

it would be like so, im not sure if you can use ELSE IF in the same line.

   msg * CPU is 64 bit
) ELSE (
   msg * CPU is not 64 bit

Edited by JohnnyJammer, 12 January 2015 - 11:18 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users