Launch deployed application with winopen
2 次查看(过去 30 天)
显示 更早的评论
Hi, I'm trying to launch an executable (application compiled with AppDesigner) from another deployed application (application compiled with AppDesigner) using the winopen function.
I get the error: Error in validating CTF manifest file.
Is there a solution?
回答(1 个)
chrisw23
2024-4-2
...
function callConsoleApplicationAsync(obj,appWorkingPath,appFileNameWithArguments)
arguments
obj
appWorkingPath
appFileNameWithArguments
end
import System.IO.*
asyncSysProc = System.Diagnostics.Process();
asyncSysProc.EnableRaisingEvents = true;
try
liEmptyProc = addlistener(asyncSysProc,'Exited',@obj.consoleProcessFinished_Callback);
catch ex
disp("Error@callConsoleApplicationAsync save listener handle " + string(ex.message))
end
try
asyncSysProc.StartInfo.CreateNoWindow = true; % true = no cmd windows pops up
asyncSysProc.StartInfo.UseShellExecute = false; % false to enable redirection
asyncSysProc.StartInfo.WorkingDirectory = appWorkingPath;
asyncSysProc.StartInfo.FileName = "cmd.exe"; % use cmd.exe to call any app
asyncSysProc.StartInfo.Arguments = "/c " + appFileNameWithArguments; % add arguments here
asyncSysProc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
asyncSysProc.Start();
notify(obj,"ConsoleProcessStartedAsync", WinNetIO.NotifyDiagArgs(string(asyncSysProc.StartInfo.Arguments)))
obj.liAsyncCmd.("P" + string(asyncSysProc.Id)) = liEmptyProc; % id available after start
catch ex
disp(ex.message)
end
end
...
Just copied a function from one of my classes to show how to call any executable asynchronous. This will not block your calling app. If you don't want to use events skip lines for listeners and notification. Be aware of missing class frame for this code snippet.
3 个评论
chrisw23
2024-4-8
编辑:chrisw23
2024-4-8
Sry for the late response. Its rigth the code snippet should be used to create a simple function as you did. This is a fire and forget call and you can call anything from the console. You could call explorer.exe instead of the Matlab executable to debug this part of your code. As you have two AppDesigner apps both are to be compiled and app1.exe needs the path to app2.exe . In the AdditionalSettings section of the AppCompiler you should enable the console output to write debug info via disp cmd for better understanding what happens when.
Check also that the Matlab Runtime version installed matches the compiler version. Another option ist to start the appdesigner app as Administrator to check if this is an priviliges error.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!