View Full Version : System() run without "start" crashes

05 May 2007, 04:31 AM
Another problem from me.

I'm trying to run an external program from MEL using:

system "C:/folder/program.exe"

This is so I can have maya wait for that to finish it's job before the script continues . However, the program crashes and gives me this error message:
Unhandled Exception: System.IO.IOException: The handle is invalid.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.Console.GetBufferInfo()
at System.Console.Clear()
at f3dvCompiler.Program.startMessage()
at f3dvCompiler.Program.Main(String[] args)

If I run it as this however:

system "start C:/folder/program.exe"

The program will run. The only problem is that the MEL script continues on it's way, even though it needs a file that is created from the program. I added a while loop that check for an existing file larger than 0kb, but what ends up happening is my script with move the file at that point, before it has all the information put into it. I will then get a separate file in the original directory that works, but isn't moved.

Any help would be greatly appreciated.

Sick Spider
05 May 2007, 04:40 AM
You can try add a pause connamd, for lets say 2 Sec'.
Might do the trick.

pause -sec 2;

Right after running the external program.

05 May 2007, 05:02 AM
Hmm, that may be useful. The only problem is that the program takes varying degrees of time to finish, from 1 second to 20 or more. It could possibly even go over a minute if the user selects some high settings.

Sick Spider
05 May 2007, 06:00 AM
By the settings change the amount of time u pause.

if ("settings" == "high")
pause -sec 20;
if ("settings" == "low")
pause -sec 2;

Or something like it....

CGTalk Moderation
05 May 2007, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.