-1

I want pass an parameter with special characters from vbs to batch file without enclosing it in double quotes.
vbs:

Set Shell = CreateObject("WScript.Shell")
Shell.Run "Test.bat ""0,(5306546...)"""

batch file:

@echo off
echo %1
pause > NUL

My goals is the output:

0,(5306546...)

And not:

"0,(5306546...)"

If the vbs were:

Set Shell = CreateObject("WScript.Shell")
Shell.Run "Test.bat 0,(5306546...)"

L'output of the batch file would be:

0

This question is different because I didn't know the %~1 command before this answer.

Mario Palumbo
  • 693
  • 8
  • 32
  • 3
    Leave the quotes and strip them in the batch by using `Echo=%~0` –  Jun 13 '18 at 15:19
  • 1
    The use of the tilde in the answer below is documented in the `CALL` and `FOR` commands help files. – Squashman Jun 13 '18 at 16:38
  • Possible duplicate of [What does %~d0 mean in a Windows batch file?](https://stackoverflow.com/questions/112055/what-does-d0-mean-in-a-windows-batch-file) – user692942 Jun 14 '18 at 12:40

1 Answers1

2

Why not simply use

echo %~1

in your batch?

Magoo
  • 77,302
  • 8
  • 62
  • 84