There's a missing double quote at the end of the last argument of the cscript command. It should be: ... "%URL%" '
With this, the # and ! characters make it through easily.
For example this test script:
Code: Select all
@if (@a==@b) @end /*
@echo off
setlocal
set "URL=http://127.0.0.1:99999/page/index.html#!/area/999...long string here containing just letters and numbers...999/site"
for /f "delims=" %%I in ('cscript /nologo /e:jscript "%~f0" "%URL%" %*') do (
echo CSCRIPT output: %%I
)
exit /b
*/
var args=WScript.Arguments;
for (var i = 0, len = args.length; i < len; i++) {
var arg = args.Item(i);
WScript.Echo("arg[" + i + "] = " + arg);
}
WScript.Quit(0);
Results:
Code: Select all
C:\JFL\Temp>test ! % #
CSCRIPT output: arg[0] = http://127.0.0.1:99999/page/index.html#!/area/999...long string here containing just letters and numbers...999/site
CSCRIPT output: arg[1] = !
CSCRIPT output: arg[2] = %
CSCRIPT output: arg[3] = #
C:\JFL\Temp>
Of course, you must respect all batch syntax rules.
For example, if you have two exclamation points in your URL, and variable expansion is enabled, then the !section_of_your_url! will be expanded, probably to an empty string!
The workaround is to use !URL! instead of %URL% in this case.