Filter löschen
Filter löschen

How to update a GUI programmatically

4 Ansichten (letzte 30 Tage)
Andy S
Andy S am 17 Jul. 2020
Beantwortet: Andy S am 17 Jul. 2020
I'd like to offer the user the opportunity to automatically update a GUI to the latest version. I can check for and download an updated installer if available. The main challenge is to exit the GUI after launching the installer so it can be overwritten. It would be nice to restart the GUI after installation too. The following code doesn't work, because system waits while the installer is running, so the installer can't overwrite the GUI because it's in use.
status = system('GUIInstaller'); %run the installer for the new version
if status==0
% if successfully executed, close application
closereq();
ImaginaryCommandToRestartTheApplication()
end
Is there a way of launching the installer and not waiting for it to complete?
I'm using the Matlab Compiler App to create the installer, so it's not hugely versatile.

Akzeptierte Antwort

Andy S
Andy S am 17 Jul. 2020
In framing my question, I realised what I should have been looking for. By placing an ampersand after the command, the system command does not wait. I then studied the command format for Windows cmd, and discovered you can run consecutive commands. So the following code now runs the installer, followed by restarting the app (assumes it's installed in the same location as the original), while closing the original instance:
% find path of executable
if isdeployed % Stand-alone mode.
[~, result] = system('set PATH');
ExecutablePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % Running from MATLAB.
ExecutablePath=pwd;
end
% launch the installer, and then the newly installed GUI, without waiting
system(['GUIInstaller, ' && "', ExecutablePath,'GUIExecutable"',' &']);
closereq();
The code for finding the path of the executable so it can be relaunched came from:

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by