On Windows 7....
This SO Answer seems to be in error for me: Use of Percent Sign as a CMD Parameter
In Called.bat
echo 1=%1
Caller Bat
call called.bat "percent%%sign"
Results
percent%%sign = percent
"percent%%sign" = "percent"
percent^%sign = percent
"percent^%sign" = "percent^%sign"
percent%%%%sign= percent
percent%%%sign= percent
"percent%%%%sign" = "percent"
"percent%%%sign" = "percent"
caller
@ECHO OFF
SETLOCAL
CALL qq22658604 "percent%sign"
CALL qq22658604 "percent%%sign"
CALL qq22658604 "percent%%%sign"
CALL qq22658604 "percent%%%%sign"
CALL qq22658604 percent%sign
CALL qq22658604 percent%%sign
CALL qq22658604 percent%%%sign
CALL qq22658604 percent%%%%sign
GOTO :EOF
qq22658604
@ECHO OFF
ECHO 1=%1
GOTO :EOF
results
1="percentsign"
1="percentsign"
1="percentsign"
1="percent%sign"
1=percentsign
1=percentsign
1=percentsign
1=percent%sign
NFF.
When I use a second.bat
with
@echo off
echo %~1
There are two cases now.
If you call second.bat
from a batch file, the CALL
line in the caller batch needs to be
call called.bat "percent%%%%sign"
You could omit the quotes, as long as there are no spaces inside the parameter
If you call the called.bat
directly from the cmd-prompt you can use
call called.bat "percent%sign"
Ok, this one is my bad. The issue is caused by cmd shell software called "Take Command" v13 by JP Software. The echo command is behaving differently. I have no insight on how to get it working correctly at this time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.