1

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?

1
  • 2
    There is no such folder as C:\Prorgram Files. Check your spelling of Program. Neither the batch file or the command line version will work with that spelling. Commented Jan 22, 2013 at 1:39

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.