简体   繁体   中英

passing the '=' sign as a parameter to a bat file

I'm trying to launch a exe from a bat file using the following code

start "" "abc.exe" %1 %2 %3 %4

my first argument (%1) is a encrypted authentication id, this id includes two = sings at the end

my problem is every time i pass %1 argument , those two = signed are dropped by the bat file.

as a result i can't run the application as i expect.

please give me some idea on how to solve this problem

--Rangana

If you start an exe program, it should be able to parse all it's command.

Therefore you should be sure that your parameters are really contain the expected data.

You could try it with hardcoded parameters.

start "" "abc.exe" a$deD343aD5== param2 param3 param4

Batch treats the following characters as parameter delimiters: <space> <tab> , ; = <0xFF> <space> <tab> , ; = <0xFF> . Note that <0xFF> is a non-breaking space.

The only way to include any of the delimiters as part of a parameter value is to enclose the parameter in double quotes.

It is up to the caller to enclose the value in quotes. So if the 1st parameter should be a$deD343aD5==, then your batch script must be called as

scriptName "a$deD343ad5==" param2 param3 param4

If you don't want to pass the quotes to your exe, then you can use the ~ modifier within your batch script to trim the enclosing quotes. But you have to be careful because special characters like < > & | will cause problems if they are not quoted or escaped.

::This will preserve any enclosing quotes around each parameter
start "" "abc.exe" %1 %2 %3 %4

::This will strip any enclosing quotes around each parameter (if they exist)
start "" "abc.exe" %~1 %~2 %~3 %~4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM