Howto execute external file ...

BlitzMax Forums/BlitzMax Programming/Howto execute external file ...

How to execute external file (like sh or bat file )from bmx code? Blitz3D has ExecFile(...) and Blitzmax?

OpenURL("filename.bat")

thx

Any idea howto wait on end of executed prgoram? (for showing result)

Try system_ such as system_ "notepad.exe"
Might also want to lookup createprocess for more control and do a search on execfile for other solutions.

OpenURL() should only open a external browser when available.

I think you want to use PUB.FreeProcess

Local app:String = "notepad.exe"
'Check if file exists
If FileType(app) = 1
	'Execute application
	Local process:TProcess = CreateProcess(app)
	Repeat
		Local error:String = process.err.ReadLine()
		If error <> "" Then
			Notify error
		EndIf
		If process.Status() = 0 Then Exit
	Forever
Else
	Notify "Unable to execute " + app
EndIf


For my purpose I've left out the repeat block since it was hurting performance for me. But this is how I launch external apps.

OpenURL() should only open a external browser when available.
OpenURL() will open any file with its default application.

If its a HTML file, it'll open it in the default browser.
If its a .BMX file, it'll open MaxIDE.exe.

etc.

@Htbaa:
yes. this is good and work nice, thx a lot