Home  >  Q&A  >  body text

Incorrect filename, directory name, or volume label syntax in batch process

<p>When I run the following command in batch... </p> <pre class="brush:php;toolbar:false;">set PATH='C:UsersDEBDownloads10.1.1.0.4' cd !PATH!</pre> <p>I get the error "The file name, directory name, or volume label syntax is incorrect"</p> <p><strong>Update</strong>: Some solutions worked for me. </p> <ul> <li>Do not use <code>PATH</code> as a variable name</li> <li>Set it to <code>"myPATH=C:UsersDEB DASDownloads10.1.1.0.4"</code></li> </ul><p><br /></p>
P粉396248578P粉396248578389 days ago470

reply all(2)I'll reply

  • P粉463291248

    P粉4632912482023-08-28 13:28:01

    In my case, if I run the batch file using cmd and the batch file path is incorrect, this error will show up, like users>E:\TEST"E:\TEST.batError, users>E:\TEST.bat worked. After checking my path, it was fixed.

    reply
    0
  • P粉184747536

    P粉1847475362023-08-28 11:15:29

    set myPATH="C:\Users\DEB\Downloads.1.1.0.4"
    cd %myPATH%
    • Single quotes don't represent strings, they make it start with: 'C:\ instead of C:\ so

    • %name% is a common syntax for expanding variables. The !name! syntax requires the command setlocal ENABLEDELAYEDEXPANSION< 来启用首先 /code>, or CMD /V:ON Run command prompt.

    • Don't use PATH as your name, it is the system name that contains the location of all executable programs. If you override it, random parts of the script will stop working. If you plan to change it, you need to do set PATH=%PATH%;C:\Users\DEB\Downloads\10.1.1.0.4 to keep the current PATH contents and add something to the end .

    reply
    0
  • Cancelreply