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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:45:38+00:00 2026-06-16T03:45:38+00:00

Why following commands works without any problems: set PATH=C:\Program Files (x86)\Path\With whitespaces\ if defined

  • 0

Why following commands works without any problems:

set PATH=C:\Program Files (x86)\Path\With whitespaces\
if defined APP_HOME set PATH=.;%PATH%

But there is error “\Path\With was unexpected at this time” if I use “if ” with parentheses

set PATH=C:\Program Files (x86)\Path\With whitespaces\
if defined APP_HOME ( 
   set PATH=.;%PATH%
)
  • 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-06-16T03:45:39+00:00Added an answer on June 16, 2026 at 3:45 am

    The ) character is sometimes special, sometimes not.

    If there is an active (, then the next unquoted, un-escaped ) will close the block.

    If there is not an active (, then unquoted, un-escaped ) in a command argument will simply be treated as a literal.

    Your PATH variable contains ) which is closing your IF block prematurely. In your case it can be fixed by adding quotes around the assignment.

    set PATH=C:\Program Files (x86)\Path\With whitespaces\
    if defined APP_HOME ( 
       set "PATH=.;%PATH%"
    )
    

    But be careful. Sometimes the PATH contains paths that are already quoted. Enclosing the assignment in quotes can possibly break the assignment if there are already quotes within PATH.

    Here is a foolproof way of prepending a value to PATH, regardless what the current definition is. The code assumes delayed expansion is initially disabled.

    set PATH=C:\Program Files (x86)\Path\With whitespaces\
    if defined temp (
      setlocal enableDelayedExpansion
      for /f "eol=: delims=" %%P in ("!path!") do endlocal & set "PATH=.;%%P"
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use the following code in command prompt, it works fine. But when
I added following command to Sessions -> Startup program but it didn't work. I'm
I have a LAMP server where I've run the following commands to set permissions
I want to remove localhost from the string but the following commands are not
I am having trouble with the following command prompt commands (in Windows XP). set
I have the following awk command which works perfectly: awk 'BEGIN { ORS =
I have the following commands in a README file: ./Setup ... ./Setup ... ./Setup
You usually invoke the following commands to build a ./configure d product: make make
I chrooted directory using following commands: os.chroot(/mydir) How to return to directory to previous
The Roku media player provides a RESTful API with the following commands: query/apps This

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.