我正在开发一个简单的应用程序,该应用程序应该加密命令行给出的字符串,然后将其写入注册表。不幸的是,如果密码包含特殊字符,例如 " & < > |
.所以例如:
Encrypt.exe /Password:Password /reg --> works fine
Encrypt.exe /Password:Password"&<>| /reg --> the password variable contains: Password&<>| /reg which is wrong
Encrypt.exe /Password:Password&<>| --> this outputs: "> was unexpected at this time." but no idea where this text is coming from
Encrypt.exe /Password:"Password&<>|" --> this works, but note that the password can't contains a " char and the encrypted/decrypted string will contain a " at the beginning and at the end
所以我的问题是,如何将字符串Password&<>|
正确传递给我的应用程序?
转义.bat文件中的某些字符:
& use ^&
< use ^<
> use ^>
| use ^|
" use ""
供参考:https://www.robvanderwoude.com/escapechars.php