2

I have a batch file which opens a pop-up within a website. The website opens fine, but when I want to add a parameter with a plus character, +, it doesn't work!

The code looks like this:

@echo off
start "Chrome" chrome --app=https://website.com?phone=%1

However the %1 will be replaced with the incoming number but without the + before it.

I don't why that happens so I tried to add a plus manually.

@echo off
start "Chrome" chrome --app=https://website.com?phone=+%1

But that doesn't work either!

Does anyone have an idea how to add the + sign to the url?

The desired result should be:

https://website.com?phone=+3112345678
Compo
  • 36,585
  • 5
  • 27
  • 39
Webdeveloper_Jelle
  • 2,868
  • 4
  • 29
  • 55

1 Answers1

2

That's because + is the url encoding for space.

To encode a plus sign you have to use %2b.
But in batch-files the percent sign is also a special character, therefore it has to be escaped itself by another percent sign.

 https://website.com?phone=%%2B555-123

And the url should be quoted, because when more than one get parameter is present, then these parameters are separated by & signs, that collides again with the special meaning in batch files for command separation.

start "Chrome" chrome --app="https://website.com?phone=%%2B%1&name=John"
jeb
  • 78,592
  • 17
  • 171
  • 225