在cmd中转义特殊字符 [英] Escaping special characters in cmd

查看:2304
本文介绍了在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屋!

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