windows - 带 % 和 ^ 的 CMD

标签 windows batch-file cmd

我有一个 file.bat,我在 Windows 中通过命令行运行它。

密码需要读取%^等字符

当我运行脚本时,我发现 shell 没有读取这些字符。

我能做些什么来解决这个问题??

最佳答案

您需要使用 ^ 对它们进行转义。

要转义 ^,您可以使用另一个 ^^

正如 jeb 正确指出的那样,您无法在命令行上转义 %,但是当在变量字符串中使用它们设置变量时,它似乎接受了它们。

set p=hello%
echo %p%
hello%

关于windows - 带 % 和 ^ 的 CMD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13273521/

相关文章:

string - Windows批处理文件-在文件中查找字符串并将其追加

powershell - teamcity powershell-无法运行批处理文件

java - JAVA 中的窗口句柄

windows - Apache Ant : Terminate process started by <exec> when ant process is terminated

Windows 启动时 C++ 应用程序自动运行

batch-file - 通过将文件夹作为批处理脚本的输入来更改多个文件夹图标

windows - 如何从 PATH 环境变量中提取完整路径?

if-statement - 当我通过管道传送到 IF 命令时会发生什么?

google-app-engine - 谷歌应用引擎: how to logout of appcfg from cmd

batch-file - 以不同用户身份运行cmd并执行命令行的批处理文件