简体   繁体   English

将'='符号作为参数传递到bat文件

[英]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 我正在尝试使用以下代码从bat文件启动exe

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

my first argument (%1) is a encrypted authentication id, this id includes two = sings at the end 我的第一个参数(%1)是一个加密的身份验证ID,此ID末尾包含两个=唱歌

my problem is every time i pass %1 argument , those two = signed are dropped by the bat file. 我的问题是,每当我传递%1参数时,bat文件就会丢弃这两个=符号。

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. 如果您启动一个exe程序,它应该能够解析其所有命令。

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> <space> <tab> , ; = <0xFF> . <space> <tab> , ; = <0xFF> Note that <0xFF> is a non-breaking space. 请注意, <0xFF>是不间断的空格。

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 因此,如果第一个参数应为a $ deD343aD5 ==,则必须将批处理脚本调用为

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. 如果您不想将引号传递给您的exe,则可以在批处理脚本中使用~修饰符来修剪包围的引号。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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