Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7278313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:51:27+00:00 2026-05-28T22:51:27+00:00

I have the following in a BAT file: @echo off Set /P _environment =

  • 0

I have the following in a BAT file:

@echo off

Set /P _environment = Please Enter Environment [d] for Development or [a] for Acceptance:

IF ((%_environment% EQU "a") OR (%_environment% EQU "d"))
(goto sub_write_files)
ELSE
(goto end)


:sub_write_files
xcopy script_temp\* \\CHU-%_environment%101\CHU\scripts /D /E /C /R /I /K /Y /S
:end
echo %_environment% Done

The logic seems well formed to me, but possibly it is not because the sub_write_files sub routine every time that I fire this command. I am assuming that the flaw is in the conditional logic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:51:28+00:00Added an answer on May 28, 2026 at 10:51 pm

    You need to brush up on your batch syntax. Help is available for just about every command by typing either HELP command or command /? at a command prompt. For example, HELP IF will provide help on the IF command. Granted, the documentation is often incomplete and/or confusing, but it is a start.

    You have lots of problems with your syntax as written. One of the most obvious is IF does not support any operators like AND, OR, XOR etc.

    You can achieve the logic you were looking for with the following

    @echo off
    
    Set /P _environment = Please Enter Environment [d] for Development or [a] for Acceptance:
    
    if "%_environment%" neq "a" if "%_environment%" neq "d" goto :end
    :sub_write_files
    echo xcopy script_temp\* \\CHU-%_environment%101\CHU\scripts /D /E /C /R /I /K /Y /S
    :end
    echo %_environment% Done
    

    There are lots of potential improvements. For example, you might want to add the /I option to both IF statements so that case does not matter. Or you might want to loop back and try again instead of ending if an invalid value is entered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following batch file echo Setting visual studio 2010 environment variables set
I have this test.txt file with the following content: @echo off wget -q http://subs.ro/get/21518
I have the following thing in my bat file. say set path=c:\temp\test so basically
I have the following line in a BAT file, it does not work, how
I have a .bat file with the following structure: istruction1[newline] I would like to
I have a batch file (BAT1.bat) which returns the following string: Login credential: 7o5g4cika
I have the following problem. I got a bat file that runs testcomplete test.
I have the following line in a bat file: xcopy script_temp\* \\CHU-Computer-Science\CHU\scripts\ /S /E
I have the following code $env=array('PATH'=>'C:\Program Files\MySQL\MySQL Server 5.1\bin', 'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'); $cmd='mysql --port=3306
I have following text in a file 23456789 When I tried to replace the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.