I am trying to pass an argument to a BAT file thru VB Shell function. argument text value looks like this say Hello&123
As you noticed there's an '&' as text in it. However & is reserved in BAT so I am trying to make it work but so far unsuccessful.
My VB 6 code is
Dim passwd
passwd = "Hello^&123"
retval = Shell("C:\test.bat " & passwd, vbNormalFocus)
I have tried following combinations but none work. So I am clueless what value should I set to variable passwd in VB 6 that will accept Hello&123 as correct text parameter in BAT.
Errors I receive
passwd = "Hello^&123"
Hello
'123' is not recognized as an internal or external command,
passwd = """Hello^&123"""
"Hello^&123"
passwd = "Hello&&123"
Hello
However none of the above are useful as I want %1 to be exactly as Hello&123
Any further help will be great.
Edit...
The batch file just now simply has echo command.
@echo off
echo %1
pause
Thanks.
&
in quotes work because it loses the special meaning inside quotes. Probably the issue is in the way you're printing the variable. What's the content of the batch file?^^^&
.