How to pass empty file to batch file as parameter

I need to pass an empty ("or" ") batch file as a parameter.

I need to pass runtime values ​​to a url. My URL:

start iexplore http://example.com?emailAddress=%1&name=%2&phone=%3&dateofbirth=%4&hobby=%5&address=%6

Everything works fine if all parameters have some value, but if the value of any of the parameters is "or" ", that is empty, the next non-empty value is an assignment, and the sequence is messy.

Please, help!

+4
source share
2 answers

Use %~xinstead %x(where x is the number of your parameter)

This removes any closing quotes from the paramater, therefore

echo parameter3=%~3

will show parameter3=

if you called it with yourbatch one two "" four

" space "as a parameter then this will show a space as% ~ 3` ( - )

, %x, - "", " " , . , , ...

+5

alt + 0255 a.bat

a = "ÿ" echo "ÿ" set/p c = "gg"

ÿ emptysace ignore set/p c = "gg", , u -

0

Source: https://habr.com/ru/post/1526360/


All Articles