Can't run an external program with arguments

This question is closely related to:
Executing the following command in Matlab (R2019a) causes a not repsponding error in my external program to appear
cmdStr1 = ['"C:\Program Files (x86)\SGeMS\sgems-x64.exe"']
system(cmdStr1)
Using the answer in [1] from:
Philipp Krauter on 30 Dec 2018
I can successfully get Matlab (R2019a) to execute my program using the following
cmdStr2 = ['set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files (x86)\SGeMS\sgems-x64.exe"']
system(cmdStr2)
However as soon as I include the arguments
cmdStr3 = ['set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files (x86)\SGeMS\sgems-x64.exe" -s tiGenerator.py']
system(cmdStr3)
I get the initial not responding error again.
This appears to be an issue with Matlab as I can execute the command successfully in the command line.
Note, using the suggestion of dos() from Image Analyst results in the same error
Any help would be appreciated!

8 Comments

Avoid the useless square brackets - they are the operator for array concatenation, but you have a single input only.
I do not see the difference between the two calls:
cmdStr2 = 'set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files (x86)\SGeMS\sgems-x64.exe"'
cmdStr3 = 'set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files (x86)\SGeMS\sgems-x64.exe"'
Is there a typo?
Please see edited question, cmdStr3 should read:
cmdStr3 = ['set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files (x86)\SGeMS\sgems-x64.exe" -s tiGenerator.py']
similar problem here (I cannot get to run an .exe even without arguments). Is there any update on the issue?
What is the problem, what is the program?
Hi @MarioMalic,
My problem is the same as mentioned above: I can run without problems the following commands from DOS console:
C:\Users\ana.fernandez>"C:\[long path here]\Programas\POSC2_R14.48_p\Portable\POSC2.exe"
C:\Users\ana.fernandez>"C:\[long path here]\Programas\POSC2_R14.48_p\Portable\POSC2.exe" "C:\Users\ana.fernandez\posc2_command_line.auto" RAINFLOWS
but I get this when doing it from within Matlab:
>> [status,results] = system('"C:\Users\ana.fernandez\[long path here\Programas\POSC2_R14.48_p\Upgrade\POSC2.exe"')
status =
-1.0737e+09
results =
0×0 empty char array
>> dos( '"C:\Users\ana.fernandez\[long path here]\Programas\POSC2_R14.48_p\Upgrade\POSC2.exe" posc2_command_line.auto RAINFLOWS')
ans =
-1.0737e+09
The workaround with the 'set path' doesn't work for me. By the way I am using 2020a.
>> [status,results] = system('set path=%path:C:\Program Files\MATLAB\R2020a\bin\win64;=% & "C:\Users\ana.fernandez\[long path here\Programas\POSC2_R14.48_p\Upgrade\POSC2.exe"')
status =
-1.0737e+09
results =
0×0 empty char array
Can you move with your current MATLAB directory to that folder and do this
system('POSC2.exe')
Would that call the software?
You can try this answer as well if the above doesn't work properly.
Hi @MarioMalic, problem solved thanks to your assistance. The program runs with system('POSC2.exe'); I changed the path to the program and that's it.
That's great to hear. Usually, you wouldn't run the program from its directory. You should try it from some other directory where you're writing the code. Probably, the software could not be opened maybe due to the read/write access in the current directory, as any files that program generates (session file), will be within the current directory of MATLAB.
I just wanted to check whether it's possible to call it within the program folder. This might indicate an issue with your paths, or r/w access as mentioned above.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2019a

Asked:

on 5 Aug 2020

Edited:

on 13 Oct 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!