How to escape characters in Windows Batch?

Asked

Viewed 342 times

6

I have the following script:

start "" "https://site.com.br/app/index.jsf?username=nomecabuloso&token=tokenzera"

But when I do, it’s only index.jsf, it opens the following url:

https://site.com.br/app/index.jsf

I’ve tried using the escape key \, to the ?, but it doesn’t work.

My question is, how to make it run the entire link?

  • It was because the quotation marks had already escaped the characters.

3 answers

9


To clear characters use the circumflex accent ^

  • 1

    @Francis the & is a special character so you need a ^ in it also.

  • 1

    I got it. I got it working, vlw.

1

You don’t need any of that,:

@echo off
start chrome "https://site.com.br/app/index.jsf?username=nomecabuloso&token=tokenzera"

Obs: change the browser name to the browser you will open.

0


inserir a descrição da imagem aqui


To use by passing argumento/parâmetro and not requiring previous edits in characters especiais present in the link.


Basically, the bat will play the argument/parameter (%1) in the loop for and already added quotes (usebackq)


Q236618.cmd "%1"


Q236618.cmd "https://site.com.br/app/index.jsf?username=nomecabuloso&token=tokenzera"

Código Q236618.cmd with argument '%1' in the for using usebackq...


@echo off & for /f usebackq %%i in ('%1')do start "" /b %%i

Código Q236618.cmd with '%1' or 'link' right in the for using usebackq filtered in a if...


@echo off 
if not ".%~1" == "." (for /f usebackq %%i in ('%1')do start "" /b %%i) else (
for /f usebackq %%i in ('"https://site.com.br/app/index.jsf?username=nomecabuloso&token=tokenzera"')do start "" /b %%i)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.