Run a python exe from within a Matlab exe with Administrator permissions
I would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017bI would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017b I would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017b system, python exe, matlab exe MATLAB Answers — New Questions