在cmd中转义特殊字符 [英] Escaping special characters in cmd
问题描述
我有一个Windows .bat脚本,其中我尝试在参数中运行带有密码的命令。我想要能够使用的密码是〜!@#$%^& *()_ + | - = \] [{}';:/.&? ; >这里,我应该用
^
转义 ^& | \<>
。从我假设,我应该逃避与
\
。
这给我这样的东西:
runme.exe / password:〜!@#$%^ ^^& *()_ + ^ | - = ^ \] [{}';:\/.^>?,^ <
但它不工作 - 我的目标应用程序响应登录失败。
我应该如何转义所有这些字符,以便能够在我的批处理密码(忽略安全问题现在)?
加倍密码中的报价,并确保完整的密码也包含在报价中:
runme.exe /password:\"~!@#$%%^^^&*()_+^|-=\][{}';:\"\"/.> ;?,< 。
I have a Windows .bat script in which I try to run a command with password in parameter. The password I want to be able to use is ~!@#$%^&*()_+|-=\][{}';:"/.>?,<
.
From what I've read here, I should escape ^&|\<>
with ^
. From what I assume, I should escape "
with \"
.
This gives me something like that:
runme.exe /password:"~!@#$%^^^&*()_+^|-=^\][{}';:\"/.^>?,^<"
But it doesn't work - my target app responds with logon failure.
How should I escape all these characters to be able to hardcode the password in my batch (ignoring the security issues by now)?
Double the quote in the password and make sure the complete password is enclosed in quotes as well:
runme.exe /password:"~!@#$%%^^^&*()_+^|-=\][{}';:""/.>?,<"
这篇关于在cmd中转义特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!