Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何将配置文件传递到bat文件中的exe?_Batch File_Exe - Fatal编程技术网

Batch file 如何将配置文件传递到bat文件中的exe?

Batch file 如何将配置文件传递到bat文件中的exe?,batch-file,exe,Batch File,Exe,我已经在我的计算机上的同一目录中安装了test.exe(控制台应用程序/windows应用程序)和test.exe.config 当我打开DOS提示符时,我能够运行test.exe%1%2%3,它成功地将数据插入MS SQL表中 test.exe.config是从app.config编译而来的,其中包含以下内容: <connectionStrings> <add name="Common Instance" connectionString="data source=eeeee

我已经在我的计算机上的同一目录中安装了test.exe(控制台应用程序/windows应用程序)和
test.exe.config

当我打开DOS提示符时,我能够运行
test.exe%1%2%3
,它成功地将数据插入MS SQL表中

test.exe.config是从app.config编译而来的,其中包含以下内容:

<connectionStrings>
<add name="Common Instance" connectionString="data source=eeeeee;Integrated Security=SSPI;Initial Catalog=YYYY;User ID=xxx;Password=xxxx" providerName="System.Data.SqlClient"/>
</connectionStrings>
我在数据库上放了一个跟踪,当我运行bat文件时,它甚至没有被击中

似乎当我运行bat文件时,它找不到数据库连接

我试过:

START C:\aa\test.exe%1%2%3“test.exe.config”

START C:\aa\test.exe%1%2%3/config:test.exe.config

START C:\aa\test.exe%1%2%3/config:App.config


它们都不起作用。我希望有一些提示。

我的猜测是需要在批处理文件中设置工作目录。这就是它找不到
.config
文件的原因。将工作目录设置为应用程序和
.config
文件所在的文件夹

cd C:\aa
start test.exe %1 %2 %3
cd C:\aa
start test.exe %1 %2 %3