File .exe not recognized as an internal or external command

15 views (last 30 days)
I am trying to run a .bat file which runs an .exe file. The .exe file run a file and print a result. I leave here the text of the .bat file, which runs perfectly if I double-click on it.
ECHO OFF
tpgigm.exe both MODELLOLL15_0.atp MODELLOLL15.lis -R
FYI, the program I am trying to run is ATP, en electromagnetic transient program. If you run the .atp file in the tpgig.exe compiler, you get the simulation results in the .lis file. Both .atp and .lis are readable like a .txt file.
If I try to give Matlab the command:
system('C:\EEUG24\ATPDraw75_Image\ATP\SFK.bat');
It says:
C:\Users\Feder\MATLAB Drive\TESI>ECHO OFF
"tpgigm.exe" it is not recognized as an internal or external command, program or batch file executable.").
And if I try to run
system('C:\EEUG24\ATPDraw75_Image\ATP\tpgigm.exe both MODELLOLL15_0.atp MODELLOLL15.lis -R','-echo');
instead, It gives me problems with ATP itself; it runs in matlab, but it has problems to load the startup file. It's an ATP error inside Matlab.
How can I make "recognisable" for matlab the tpgig.exe file to run the batch?
Thanks for your help!

Answers (1)

Swastik Sarkar
Swastik Sarkar on 12 Nov 2024
Moved: Image Analyst on 13 Nov 2024
It seems likely that the batch script is being executed from a directory different from where tpgigm.exe is located. The batch script requires tpgigm.exe to be either in the same directory as the script or added to the Windows Path Variable. Otherwise, the error message
tpgigm.exe is not recognized as an internal or external command, program or batch file executable
will appear.
To resolve this issue, consider changing the directory to where the executable is located before running the script through system command.
  1 Comment
Federico
Federico on 13 Nov 2024
Moved: Image Analyst on 13 Nov 2024
Thanks for the answer!
I modified the .bat file specifying all the paths and directories. Now the .bat will run in Matlab, but it gives me the same problem that he gave me before, namely, the ATP error inside matlab, the one to load the startup file.
My question is; given that if I double-click on the .bat file it worls perfectly, is there a command in Matlab that phisically double-clicks on the .bat file?
The .exe don't have to run in matlab, It just have to run outside, I don't want results in matlab beacuse I already have the program to read the results of the .lis file.
I hope that you understand what my request is, I just want Matlab to run the .bat like if i was double-clicking on it.
EDIT:
I solved my problem!
I had to specify every path in the .bat file and, to run properly ATP, I had to copy the matlab script (.m file) in the folder where the tpgig.exe was! This last thing solved the ATP initialization process.
Now i call the .bat :
system('C:\EEUG24\ATPDraw75_Image\ATP\SFK_N.bat > NUL','-echo');
To avoid the writing of all of the .bat result on the command window i added ( fundamental ) :
'>NUL'
Thanks for the answer!

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!