I need to pass blank("" or " ") to a batch file as parameter.
I have to pass the runtime values to a url. My url is:
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 " ", i.e., blank, the next non-blank value is assignment and the sequence is disordered.
Please help !
To create a blank line in a batch file, add an open bracket or period immediately after the echo command with no space, as shown below. Adding @echo off at the beginning of the batch file turns off the echo and does not show each of the commands. @echo off echo There will be a blank line below. echo.
Batch parameters (Command line parameters): In the batch script, you can get the value of any argument using a % followed by its numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on. If you require all arguments, then you can simply use %* in a batch script.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
Note: %0 is the name of the batch file. %~n0 Expands %0 to a file Name without file extension.
Use %~x
instead of %x
(where x is your parameter number)
This removes any enclosing quotes from the paramater, hence
echo parameter3=%~3
would show parameter3=
if you called this with yourbatch one two "" four
If you pass "
space"
as a parameter then this will show a space as %~3
(which is a bit hard to see - try appending an obvious string)
In either case, if you use %x
then you'd show enclosing quotes - either ""
or " "
depending on which you passed in that position. You probably don't want quotes just there...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With