简体   繁体   中英

bat file not running an .exe application?

I am trying to run an application "VolumeReconstructor.exe" from a bat file, but I get an error

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

the code is as follows:

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

What am I doing wrong?

Perhaps you are not currently on the c: drive. You would need to do this:

:: 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

But I would probably recommend using absolute paths like this:

:: 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

You also might want to double quote all those file locations for future compatibility if you ever change anything to include spaces:

:: 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

Otherwise I have to question whether or not that file is actually in that directory.

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