locked
How do I do logical operator in conditional in batch script? RRS feed

  • Question

  • Microsoft has been established for more than 40 years, yet I can't see code like:

    if (%somevariable% == "what" && %thatvariable% == "blabla" II ...) // <-- notice the && and II

    in batch script. where have you been all this time, microsoft developers?

    Thursday, October 29, 2020 3:42 AM

All replies

  • We read the documentation and do not use obsolete batch scripts.  

    This is now the 21st century.


    \_(ツ)_/

    • Proposed as answer by Vector BCO Thursday, October 29, 2020 5:18 AM
    Thursday, October 29, 2020 3:57 AM
  • vbs created 24 years ago, powershell 13 years ago - no idea why u still using batch scripts ;)

    The opinion expressed by me is not an official position of Microsoft

    Thursday, October 29, 2020 5:36 AM
  • so what is the modern way to write shell script-like for windows?
    Thursday, October 29, 2020 8:24 AM
  • starting from win 7 / 2008 server modern way is powershell, which now is build in every supported windows os and even porten on linux.

    The opinion expressed by me is not an official position of Microsoft

    Thursday, October 29, 2020 8:29 AM
  • powershell still needs git bash or WSL to run .sh file which still bothers, tbh
    • Proposed as answer by Vector BCO Thursday, October 29, 2020 11:35 AM
    • Unproposed as answer by Vector BCO Thursday, October 29, 2020 11:35 AM
    Thursday, October 29, 2020 8:36 AM
  • powershell still needs git bash or WSL to run .sh file which still bothers, tbh

    You asked a question and it was answered as best anyone could given that you are not a Windows technician or developer.  If you want to run scripts written in some other scripting language then you will want to contact the vendor for that language to find out how they support Windows.

    Your issues are to specific to you.  On Windows many other shell languages can be installed and all can be used as an adjunct to PowerShell.  Once you learn Windows these things will become obvious.


    \_(ツ)_/

    Thursday, October 29, 2020 8:41 AM
  • powershell still needs git bash or WSL to run .sh file which still bothers, tbh
    yes, for opening pdf's you still need pdf reader, for running python scripts you need python, for java applications you need java and for running bash/sh scripts you need (surprise - surprise) - bash or sh.

    The opinion expressed by me is not an official position of Microsoft

    Thursday, October 29, 2020 11:38 AM