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

  • Home
  • SEARCH
  • 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 7528015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:15:38+00:00 2026-05-30T04:15:38+00:00

I am trying to create a batch string like this: >abcd_ I have a

  • 0

I am trying to create a batch string like this: >abcd_

I have a variable called soeid, with value as abcd. So this is what i am doing, but it does not work.

set soeid=abcd

set "val1=>"
set "val2=_"
set "str=%val1%%soeid%%val2%"

echo %str%
  • 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-30T04:15:39+00:00Added an answer on May 30, 2026 at 4:15 am

    I’m sure it is working just fine. To prove it, add SET STR after you define the value, and you will see the correct value.

    The problem you are having is when you try to echo the value, the line that is executing becomes: echo >abcd_. The > is not quoted or escaped, so it is simply taking the ouput of ECHO with no arguments and redirecting it to a file named “abcd_”

    If you don’t mind seeing quotes, then change your line to echo "%str%" and it will work.

    The other option is to enable and use delayed expansion (I’m assuming this is a batch script code, and not executing on the command line)

    setlocal enableDelayedExpansion
    set soeid=abcd
    
    set "val1=>"
    set "val2=_"
    set "str=%val1%%soeid%%val2%"
    
    echo !str!
    

    Normal %var% expansion occurs early on while the interpreter is parsing the line. Delayed !var! expansion occurs at the end just before it is executed. The redirection is detected somewhere in the middle. That is why the normal expansion doesn’t work – the interpreter sees the expanded > character and interprets it as the output redirection operator. The delayed expansion hides the > character from the interpreter until after redirection is parsed.

    For more info about delayed expansion, type SET /? from the command line and read starting with the paragraph that starts with “Finally, support for delayed environment variable expansion…”.

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

Sidebar

Related Questions

I'm trying to create batch file which should have this commands: cd c:\Program files\NuSMV\2.5.2\bin\
Trying to create a user account in a test. But getting a Object reference
I am trying to create a batch script for my Windows machine that loops
I'm trying to create a batch file that will convert an Excel file to
Trying to create a batch to convert .WTV files to mpg files. The code
I am trying to create a batch file that removes tel: from a number
I'm trying to create a batch script that will delete all sub directories which
I have a C#/WPF app. I am trying to create different versions that will
I am trying to create a batch file to create a new user and
I have been trying to teach myself MEF, starting with this tutorial: http://blogs.msdn.com/b/brada/archive/2008/09/29/simple-introduction-to-composite-applications-with-the-managed-extensions-framework.aspx There

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.