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 1069049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:21:48+00:00 2026-05-16T20:21:48+00:00

Wow, never thought I would ever write anything in DOS. Now that I do,

  • 0

Wow, never thought I would ever write anything in DOS. Now that I do, I know why I never wanted to. The syntax is absurd!

Anyways I need help please.
I would like to prompt the user for input, and if a blank line is received, I would like to use the default value, like this:

set name=abraham.
set /p input=please enter your name, press enter to use %name%:
if not %input%=="" set name=%input%
echo your name is %name%

I get an error says “set was unexpected at this time.”

Can you help please?

  • 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-16T20:21:49+00:00Added an answer on May 16, 2026 at 8:21 pm

    Try

    set name=abraham
    set /p name=please enter your name, press enter to use %name%:
    
    echo entered : %name%
    

    Note that in cmd files, if nothing is entered, the var is not changed.

    Or, with the if:

    set name=abraham
    set input=
    set /p input=please enter your name, press enter to use %name%:
    if "%input%" NEQ "" set name=%input%
    echo entered : %name%
    

    Note the quotes around input in the if statement, and notice that I am clearing out input before running (or it will hold the last value if nothing is entered by the user)

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

Sidebar

Related Questions

Wow now i know I dont. Lol. I've got my structure like this: struct
WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find
Wow, I just got back a huge project in C# from outsourced developers and
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many
I've been evaluating various smart pointer implementations (wow, there are a LOT out there)
I need to get the path to the native (rather than the WOW) program
My work just gave me a quad core computer, and WOW build times are
Wow, this one is though! I'm trying to find in PHP the % of
Wow I've been all over the place with questions today and I apologize if
Wow, this should be so simple, but it' just not working. I need to

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.