批处理中的文件名,目录名或卷标签语法不正确 [英] The filename, directory name, or volume label syntax is incorrect inside batch

查看:1037
本文介绍了批处理中的文件名,目录名或卷标签语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行以下内部批处理时......

When I am running the following inside batch....

set PATH='C:\Users\DEB\Downloads\10.1.1.0.4'
cd !PATH!

我收到错误消息文件名,目录名或卷标语法不正确

I get error "The filename, directory name, or volume label syntax is incorrect"

更新:有些解决方案对我有用。

Update: There are the solutions that worked for me.


  • 不要将 PATH 用作变量名

  • 将其设置为 myPATH = C:\ Users\DEB DAS\Downloads\10.1.1.0.4

  • Don't use PATH as a var name
  • set it as "myPATH=C:\Users\DEB DAS\Downloads\10.1.1.0.4"

推荐答案

set myPATH="C:\Users\DEB\Downloads\10.1.1.0.4"
cd %myPATH%




  • 单引号不表示字符串,它们使字符串开始:'C:\ 而不是 C:\ 这样

    %name%是扩展变量的常用语法,!name!语法需要可以先使用命令 setlocal ENABLEDELAYEDEXPANSION 启用,或者使用 CMD / V:ON 运行命令提示符。

    %name% is the usual syntax for expanding a variable, the !name! syntax needs to be enabled using the command setlocal ENABLEDELAYEDEXPANSION first, or by running the command prompt with CMD /V:ON.

    不要使用PATH作为您的名称,它是系统名称tha t包含可执行程序的所有位置。如果覆盖它,脚本的随机位将停止工作。如果要更改它,则需要执行 set PATH =%PATH%; C:\Users\DEB\Downloads\10.1.1.0.4 到保留当前PATH内容,并在末尾添加一些内容。

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

    这篇关于批处理中的文件名,目录名或卷标签语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆