bat 文件没有运行 .exe 应用程序?

Posted

技术标签:

【中文标题】bat 文件没有运行 .exe 应用程序?【英文标题】:bat file not running an .exe application? 【发布时间】:2020-08-22 20:16:29 【问题描述】:

我正在尝试从 bat 文件运行应用程序“VolumeReconstructor.exe”,但出现错误

'VolumeReconstructor.exe' is not recognized as an internal or external command, operable program or batch file.

代码如下:

echo off

::Folder path
set location=D:\pigs_december\Converted_Data\test_data\

::File names
set config_file=PlusConfiguration_mysequence.xml
set image_file=TrackedImageSequence_20191207_172327_ICE_3D_Cubes_Intervall_0_1008.nrrd
::set mask_file=mask.png
::set output_file=Output.nrrd

:: Path to the VolumeReconstructor.exe (PlusTookit --> bin)
cd C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\

:: with mask, but it does not work
::VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --importance-mask-file=%location%\%mask_file% --image-to-reference-transform=ImageToReference --verbose=4
VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --image-to-reference-transform=ImageToReference --verbose=4

pause

我做错了什么?

【问题讨论】:

运行 dir C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\VolumeReconstructor.* 并发布(edit 你的帖子)结果。 使用cd /D 而不是cd,以便在需要时也更改驱动器... 谢谢大家!我让它工作了。添加绝对路径有效。 【参考方案1】:

也许您当前不在c: 驱动器上。你需要这样做:

:: Path to the VolumeReconstructor.exe (PlusTookit --> bin)
cd /d C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\

:: with mask, but it does not work
::VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --importance-mask-file=%location%\%mask_file% --image-to-reference-transform=ImageToReference --verbose=4
VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --image-to-reference-transform=ImageToReference --verbose=4

但我可能会建议使用这样的绝对路径:

:: Path to the VolumeReconstructor.exe (PlusTookit --> bin)
:: don't bother to cd to the directory
:: cd C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\

:: with mask, but it does not work
::VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --importance-mask-file=%location%\%mask_file% --image-to-reference-transform=ImageToReference --verbose=4
"C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\VolumeReconstructor.exe" --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --image-to-reference-transform=ImageToReference --verbose=4

如果您更改任何内容以包含空格,您可能还需要对所有这些文件位置进行双引号以便将来兼容:

:: Path to the VolumeReconstructor.exe (PlusTookit --> bin)
:: don't bother to cd to the directory
:: cd C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\

:: with mask, but it does not work
::VolumeReconstructor.exe --config-file=%location%\%config_file% --source-seq-file=%location%\%image_file% --output-volume-file=%location%\%output_file% --importance-mask-file=%location%\%mask_file% --image-to-reference-transform=ImageToReference --verbose=4
"C:\Users\kristjan\PlusApp-2.9.0.20200316-Win64\bin\VolumeReconstructor.exe" --config-file="%location%\%config_file%" --source-seq-file="%location%\%image_file%" --output-volume-file="%location%\%output_file%" --image-to-reference-transform=ImageToReference --verbose=4

否则我不得不怀疑那个文件是否真的在那个目录中。

【讨论】:

使用VolumeReconstrucor.exe 的绝对路径有效。谢谢!

以上是关于bat 文件没有运行 .exe 应用程序?的主要内容,如果未能解决你的问题,请参考以下文章

有个EXE程序经常挂掉,想写个bat脚本扫描后台程序没运行后自行启动EXE程序。

bat中如何批量运行exe文件?

EXE文件怎么运行后删除或删除自己

bat循环运行几个程序,比如运行五次!

如何用bat文件调用与它在同一文件夹下的某个exe程序

如何用批处理bat运行一个程序,但这个程序却无法在dos环境下运行,我系统是win7,求解!