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)?
In Windows, you can type any character you want by holding down the ALT key, typing a sequence of numbers, then releasing the ALT key.
Escape CharactersUse the backslash character to escape a single character or symbol. Only the character immediately following the backslash is escaped. Note: If you use braces to escape an individual character within a word, the character is escaped, but the word is broken into three tokens.
No escaping is used with single quotes. Use a double backslash as the escape character for backslash.
batch-file Escaping special characters Escape using caret(^) Most special characters can be escaped using the caret( ^ ).
Double the quote in the password and make sure the complete password is enclosed in quotes as well:
runme.exe /password:"~!@#$%%^^^&*()_+^|-=\][{}';:""/.>?,<"
Give this a try, but if runme.exe
's argument parser requires quotes as string encapsulators for passwords, the it's not going to work. If you need to have a quote in your password, then runme.exe needs to provide a way to escape it!
runme.exe /password:~!@#$%%^^^&*()_+^|-=\][{}';:"/.>?,<
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With