Reputation: 8577
I have a file.bat which I run via command-line in Windows.
It need to read some characters like %
and ^
for the password.
When I run the script, I see that the shell does not read these characters.
What can I do to fix this??
Upvotes: 2
Views: 418
Reputation: 57272
Try this:
setlocal EnableDelayedExpansion
set var=something
for /f "delims=" %%a ("!var!") do
(
endlocal
set "result=%%~a"
)
This will let the command prompt read the special characters from var - source
Upvotes: 1
Reputation: 31241
You need to escape these with a ^
.
To escape ^
you use another ^^
As jeb correctly pointed out you can't escape %
's on the command line, but when setting variables with them in the variable string it seems to accept them.
set p=hello%
echo %p%
hello%
Upvotes: 5