How to hide console messages for a matlab executable in batch mode

I have used application compiler in Matlab2023b to pack two executable applications (e.g. App1.exe, App2.exe).
I also chose the setting "Do not display the Windows Command Shell (console) for execution" in my project file for both of them.
App2.exe will be called inside one of the function in App1.exe, which is hard coded.
I want to run App1.exe in a batch mode and i also wrote a batch file with one command to run it.
In the terminal the console messages of App1.exe don't show up (which is expected), but the console messages of App2.exe still exist.
Actually i also tried in the batch file like "App1.exe >nul 2>&1" which makes the situation even worse, console messages of App1.exe also shou up after this adjustment. And i also already use the @echo off, but i think it was not the solution.
How can i also hide the console messages of the App2.exe?
btw. this problem didn't show in Matlab202b before.

Respuestas (1)

Not sure what things are showing up but if you don't want any then make sure you have semicolons after every line, and don't use functions like fprintf to print stuff to the command window. If you want them displayed during development but not when the compiled executable is running then you can use isdeployed to switch the code, like
if ~isdeployed
fprintf('Running standalone executable');
pwd % Echo current folder to command window.
end
Wrap code that would otherwise be in the command window and shell window like above, and then it will only print stuff when in development mode, and not print while running the standalone executable.

4 comentarios

Thank you for your information, but wrap each fprintf might not be practical in my case. Since both of my executables have loooots of such kind of functions to write in console. I'm really confused why only one of them show such messages in batch mode...
So you said during compile to not put stuff out to the command window for both of them, and neither does open a new console/shell window when you run them. But you're running app1 from a batch file and when you do that, it outputs text from App2 into the batch file console window? Did I get it right?
How are you launching the batch file? By clicking on an icon, or by opening a console/shell window and them navigating to the folder where App1 lives and typing App.bat (or whatever your batch file is called) on the command line?
Since you have the compiler you most likely have tech support so to solve this quickly, why not just call them?
I think you understand correctly, my batch file is just stored in a sub folder of the path of my App1.
Inside:
@echo off
...
echo Testing...
cd path
App1.exe !input var1! !input var2!
So each time i just click this bat, it will run my App1 directly, and also open an terminal window.
I just want it to show "Testing..." (which means the process is still going
but actually, the console messages of App2 is showing.
Maybe i can contact Matlab support, but bcs im not sure whether it was my fault or there is sth wrong for the Matlab2023b.
It doesn't matter whose "fault" it is, they will help you solve it. They can even set up a screen sharing session where they can see your screen and code.

Iniciar sesión para comentar.

Categorías

Más información sobre Standalone Applications en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Etiquetas

Preguntada:

el 28 de Ag. de 2024

Comentada:

el 29 de Ag. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by