17

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)?

NOtherDev
  • 9,542
  • 2
  • 36
  • 47

2 Answers2

17

Double the quote in the password and make sure the complete password is enclosed in quotes as well:

runme.exe /password:"~!@#$%%^^^&*()_+^|-=\][{}';:""/.>?,<"
Christian.K
  • 47,778
  • 10
  • 99
  • 143
1

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:~!@#$%%^^^&*()_+^|-=\][{}';:"/.>?,<
jon
  • 5,986
  • 5
  • 28
  • 35
  • Still no luck. What do you mean by providing a way to escape? I have no control over `runme.exe` unfortunately. Are you suggesting that `runme.exe` may not be able to support passwords with `"`? – NOtherDev Apr 24 '12 at 12:01