Change preferences by command line

Dear all,
I would like to change some Matlab preferences (the ones that you reach from the "file" menu) from the command line. I found on the newsgroup some undocumented Java commands to change them (described by Yair Altman, thanks a lot), i.e.:
edit(fullfile(prefdir,'matlab.prf')); com.mathworks.services.Prefs.setStringPref('HTMLProxyHost','XX.XXX.XX.XX'); com.mathworks.services.Prefs.setStringPref('HTMLProxyPort','X');
However those commands do not work immediately, but Matlab need to be restarded to change them. Does anyone know a way to change them immediately, without restarting Matlab?
Thanks a lot! Cheers, Manfredo

5 commentaires

Jan
Jan le 20 Mai 2011
Of course the shown command "work immediately". I assume, they do not perform the job, you want them to do, immediately. So it would be helpful, if you explain this actual job. Showing just a method, which does not work, does not contain enough information to solve a problem.
Manfred999
Manfred999 le 25 Mai 2011
Hi,
maybe I was not too clear.
The commands:
edit(fullfile(prefdir,'matlab.prf')); com.mathworks.services.Prefs.setStringPref('HTMLProxyHost','XX.XXX.XX.XX');
&
com.mathworks.services.Prefs.setStringPref('HTMLProxyPort','X');
perform the job immediately.
However, the preferences will not work immediately because (also if the Matlab preferences file, i.e. 'matlab.prf', is immediately changed) Matlab does not "refresh" the preferences unless you restart it.
Does anyone know the java commands to notify to Matlab that there have been the preferences change, or to "refresh" the proxy preferences without restarting Matlab, or any another way to obtain the same result?
Thanks a lot,
Manfredo
Jan
Jan le 27 Mai 2011
Perhaps if you show which commands you want to influence...
Walter Roberson
Walter Roberson le 27 Mai 2011
Well, urlread() for example, Jan. Manfred wants to change the proxy without restarting MATLAB.
Jan
Jan le 27 Mai 2011
@Walter: That is a vlaid assumption. But perhaps the OP uses another function. I do not like to give a speculative advice about controlling com.mathworks.net.transport.MWTransportClientPropertiesFactory methods, because this command is ugly to type...

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 27 Mai 2011

2 votes

Do you want to change the preferences, or do you just want to define a proxy manually? For the later, you could try this (I cannot test it):
M = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create();
methods(M)
EDITED: Perhaps this way - but I cannot test it, because my Matlab computer has no connection to the net.
M.setProxyUser(java.lang.String('User'));
M.setProxyPassword(java.lang.String('Password'));
M.setProxyHost(java.lang.String('Host'));
M.setProxyPort(java.lang.String('Port'));

1 commentaire

Manfred999
Manfred999 le 30 Mai 2011
Hi Jan,
thank you very much for you kind help. I would like just to define the proxy manually from the command line. I would like to influence urlread(), urlwrite() and web(). The command:
M = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create();
methods(M)
seems to be very useful for this purpose. Please, may I ask you more information about how to use it to change the proxy and the port?
Thanks a lot!
Manfredo

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by