Having trouble when OTB has to be in 'Program Files' for my install

I’m using OTB 7 within my company, however due to security restrictions it must be in Program Files.

This is fine when accessing processes within QGIS, as I have the following set to get around space issues in the paths:
image

But when I try and run from the Shell terminal I’m getting the following error:

C:\Program Files\OTB_7.0.0\bin>otbcli_ComputeImagesStatistics -il “D:/Plymouth/sx4254_DSM_2M.asc” -out //client/C$/Temp/test2.xml

‘C:\Program’ is not recognized as an internal or external command,

operable program or batch file.

2019-11-26 11:57:43 (INFO) ComputeImagesStatistics: Default RAM limit for OTB is 256 MB

2019-11-26 11:57:43 (INFO) ComputeImagesStatistics: GDAL maximum cache size is 3270 MB

2019-11-26 11:57:43 (INFO) ComputeImagesStatistics: OTB will use at most 8 threads

ERROR 1: Can’t load requested DLL: C:\PROGRA~1\QGIS3~1.10\bin\gdalplugins\gdal_MrSID.dll

127: The specified procedure could not be found.

ERROR 1: Can’t load requested DLL: C:\PROGRA~1\QGIS3~1.10\bin\gdalplugins\gdal_MrSID.dll

127: The specified procedure could not be found.

2019-11-26 11:57:43 (INFO): Estimated memory for full processing: 2.82288MB (avail.: 256 MB), optimal image partitioning: 1 blocks

2019-11-26 11:57:43 (INFO): Estimation will be performed in 1 blocks of 500x500 pixels

Processing Image (1/1): 100% [**************************************************] (0s)

It’s completing that particular task, but I’m worried it’s missing access to dll’s which might screw up more complex tasks.

Is there any way to manage the issue with the paths which contain spaces? particularly when running from the shell terminal?

Opening the above otbcli_ComputeImagesStatistics task I noticed a reference to otbcli.bat

@echo off

::

:: Autogenerated by OTB installation process

:: DO NOT MODIFY

::

set CURRENT_SCRIPT_DIR=%~dp0

if exist %CURRENT_SCRIPT_DIR%otbcli.bat (

:: Prefer using the launcher inside the script dir

set OTB_LAUNCHER=%CURRENT_SCRIPT_DIR%otbcli.bat

) else (

:: Use the one from the PATH

set OTB_LAUNCHER= otbcli.bat

)

:: start the application

%OTB_LAUNCHER% ComputeImagesStatistics %*

Which seems to reference master path structure, however it notes ‘not to modify’ in there.

set CURRENT_SCRIPT_DIR=%~dp0

if exist %CURRENT_SCRIPT_DIR%otbApplicationLauncherCommandLine.exe (
:: Prefer using the launcher inside the script dir
set OTB_CLI_LAUNCHER=%CURRENT_SCRIPT_DIR%otbApplicationLauncherCommandLine.exe
) else (
:: Use the one from the PATH
set OTB_CLI_LAUNCHER=otbApplicationLauncherCommandLine.exe
)

setlocal
:: works for install tree
if exist %CURRENT_SCRIPT_DIR%…\lib\otb\applications (
set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%…\lib\otb\applications;%OTB_APPLICATION_PATH%
)

::set GDAL_DATA, EPSG_CSV and update PATH
if exist %CURRENT_SCRIPT_DIR%…\otbenv.bat (
call %CURRENT_SCRIPT_DIR%…\otbenv.bat
)

Command line gets confused because there is a space in “Program Files”. So it leads to the error:
‘C:\Program’ is not recognized as an internal or external command,

If your path in command line has a space put quotes around it, like this: “C:\Program Files\OTB_7.0.0\bin”. This forces the command line to treat it as one command instead of two.

Try putting quotes around the path in the bat file. Maybe that will work?

Yes I use double quotes when running via command line for any containing paths that have spaces within them.

so does otbcli.bat control paths for all the other process batch files?