Reputation: 481
I am still relatively new to batch scripts. I am trying to write a script to execute some matlab commands, essentially run a matlab script on a 32 bit version and a 64 bit version from Windows 7.
When i run the commands in the DOS prompt, everything works as i expect, but when they are run as a script, i get an error message saying that the system cannot find the path specified
script.bat
@echo off
set RESTORE=restoredefaultpath
set HOMEDIRECTORY=P:\ISARLAB\IsarLab-Dev
set SCRIPTNAME=packageScript
set MATLABCOMMAND="%RESTORE%; cd %HOMEDIRECTORY%; %SCRIPTNAME%"
echo launching Matlab 32 bit ...
::32 bit Matlab on Windows
set MATLAB32BIT="C:\Prorgram Files\MATLAB\R2012b-32bit\bin\matlab.exe"
echo %MATLAB32BIT% -r %MATLABCOMMAND%
%MATLAB32BIT% -r %MATLABCOMMAND%
@echo on
output from script:
launching Matlab 32 bit ...
"C:\Prorgram Files\MATLAB\R2012b-32bit\bin\matlab.exe" -r "restoredefaultpath; cd P:\ISARLAB\IsarLab-Dev; packageScript"
The system cannot find the path specified.
I have confirmed that the path specified is correct and the correct version of Matlab is launched when this .exe is executed.
commands run at dos prompt (this works):
set RESTORE=restoredefaultpath
set HOMEDIRECTORY=P:\ISARLAB\IsarLab-Dev
set SCRIPTNAME=packageScript
set MATLABCOMMAND="%RESTORE%; cd %HOMEDIRECTORY%; %SCRIPTNAME%"
set MATLAB32BIT="C:\Prorgram Files\MATLAB\R2012b-32bit\bin\matlab.exe"
%MATLAB32BIT% -r %MATLABCOMMAND%
Can someone explain why the commands work in the dos prompt but not in a script?
Upvotes: 1
Views: 513
Reputation: 67206
The line below have an error:
set MATLAB32BIT="C:\Prorgram Files\MATLAB\R2012b-32bit\bin\matlab.exe"
should be "Program", not "Prorgram".
EDIT: Oops! I did not read Ken White's comment before posting my answer! I apologize...
Upvotes: 2