system() call on windows, R2012b & R2014b, handling error popups
Show older comments
Hi
I try to run an external program via system() call. In a normal command shell and execute from R2012b everything works as expected, in R2013b nothing happens and my status after the system call is "-1.0737e+09" (return is empty). Same behavior if I open a cmd prompt in matlab R2013b (system('cmd')) and try to start it there.
It seems like some dependency/library of the external software is not found, because if I rename the folder of one of the needed dependencies, I get the exact same behavior in R2012b. If I than run the command directly in a cmd-prompt, a msg-box error with the unavailable dependency pops up, which matlab probably cannot return?
I tried to compare every environment variable between R2012b and R2013b (by the way R2014b does not work, either) but java.lang.System.getenv() returns exactly the same values for both Matlab versions, except __COMPAT_LAYER (ElevateCreateProcess vs. DisableUserCallbackException), but setting the environment variable in R2013b to the same value as in 2012 does not solve the problem for me.
Is there any other difference between the system call in R2012 compared to R2013? Or compared to a "normal" cmd prompt?
win7 64bit, same system (i.e. hardware) for both versions
any ideas?
2 Comments
Stefan
on 22 Jan 2015
PRATIK JAISWAL
on 26 Jan 2015
I have a similar problem . I have a written code for 2012b and it works properly with old version. But for 2014b version the MATLAB crashes and says error with the file. 2012 was a better version. The 2014 is having issues big time. Can someone please help me solve this
Answers (2)
Philip Borghesani
on 26 Jan 2015
The chained commands work for me as seen buy the output of:
system(['path &set path=%path:' matlabroot '\bin\win64;=% & path']);
There may be some other problem with how your program is running.
Other possible ways to modify the path before running your program:
- use setenv from MATLAB. The system command will pick up the path from the MATLAB environment but this should not effect the executing MATLAB. You may need to do this before the first call to system because in some versions of MATLAB a system shell is held and reused.
- Create a batch file to modify the path and call your program then run that with the system command. you can even create a new command shell with cmd /k to launch the batch file allowing more isolation.
Stefan
on 4 Feb 2015
0 votes
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!