Running a .bat file that exectutes a program and passes it a password that has an exclamation point

HI,

I need help figuring out how to pass a password with an exclamation point to a program from inside a batch file.  I have tried multiple methods.  Like using SETLOCAL EnableDelayedExpansion before the line that executes the program passing it the password.

Neither of these works:

This alone:

deployssrsreports.exe "Doesn!tWork"

And also this:

SETLOCAL EnableDelayedExpansion
deployssrsreports.exe "Doesn!tWork"

When logged, with an echo, the password has no exclamation point.
ChrisWibleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
Can you change the password? How about passing 2 !!
0
ChrisWibleAuthor Commented:
I can't change the password.  I really want my scripts to not care what the password is.  Thanks for the response, though.
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Delayed Expansion is the reason for that, so enabling it will not change anything ;-). You need to disable it:
   setlocal DisableDelayedExpansion
but that might not work either whenever a subshell is called. For this purpose it should work.
Ohter than that you have to prefix %!&() and some more with a caret: ^! for example.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Steve KnightIT ConsultancyCommented:
You can do something like this with ^ to escape the ! as long as it is in quotes.

echo "^!DDLS"

i.e.

SETLOCAL EnableDelayedExpansion
deployssrsreports.exe "Doesn^!tWork"

Open in new window


[Edit: Sorry Qlemo, duplicated your comment there, doing other things at the same time]
0
Joe Winograd, Fellow&MVEDeveloperCommented:
With EnableDelayedExpansion, you can send it with:

^^!

Regards, Joe
0
ChrisWibleAuthor Commented:
Excellent!  I am toooo overworked!  I should have seen this!  Thank you so much!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.