Reputation: 255
I execute the Matlab script file using system() which uses the command prompt and it's working fine. But i wish to hide everything and hope it runs in the background and only showing my GUI from the script file. Any idea?
This is my command in MSVS C++ (Note : i cut short the path name for simplicity purposes) :
system("\"\"C:\\matlab.exe\" -nodisplay -nosplash -nodesktop -r \"run('C:\\main.m');\"\"");
Upvotes: 0
Views: 767
Reputation: 15511
You could try CreateProcess
instead of system
. A simple example:
#include <windows.h>
#include <stdio.h>
int main() {
PROCESS_INFORMATION pi;
STARTUPINFO si = {
sizeof(si),
NULL, NULL, NULL,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL
};
BOOL res = CreateProcess(
NULL,
"C:\\matlab.exe -nodisplay -nosplash -nodesktop -r \"run('C:\\main.m');\"",
NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL,
NULL, // starting directory (NULL means same dir as parent)
&si, &pi
);
if (res == FALSE) printf("CreateProcess failed\n");
return 0;
}
Upvotes: 1