1

I am looking to create a very simple batch file to open a URL. It's so simple I'm just usingstart URL.

The problem is that in the URL there are some '=' signs ie.context=user&overlay=node and this is stopping the batchfile from opening the full URL.

How can I stop this.

Kind regards

Matt

Matt Bartlett
  • 348
  • 1
  • 3
  • 21
  • 3
    Have you tried to put the URL in double quotes? Like this: `start "" "URL"` – 303 Jun 15 '17 at 11:39
  • You could also escape characters to not being interpreted by cmd.exe with a caret `^=^|^<^>^&^,^;` as you see @Treintjes comment makes more sense in most of the cases. –  Jun 15 '17 at 12:21
  • 1
    Possible duplicate of [How do I escape ampersands in batch files?](https://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files) – phuclv Jun 15 '17 at 13:18
  • As @LưuVĩnhPhúc notes, it's the ampersand that's causing the problem, not the equals sign. – TripeHound Jun 15 '17 at 15:32

2 Answers2

1

You should probably url-encode the equal signs to %3D - see for instance https://en.wikipedia.org/wiki/Percent-encoding.

cjs1978
  • 477
  • 3
  • 7
  • 2
    The snippet the OP showed looks like they _need_ to be equals signs as they appear to be setting query values -- you would encode an equals sign if the _value_ contained an equals: `...&search=abc%3Ddef&...`. – TripeHound Jun 15 '17 at 15:29
1

& and = are specials characters in batch scripting. Just quote the URL and pass an empty string as the title like that :

@echo off
start "" "https://example.com/context=user&overlay=node"
Hackoo
  • 18,337
  • 3
  • 40
  • 70