Create Process

BlitzMax Forums/BlitzMax Programming/Create Process

Bertrand(Posted 2005) [#1]
How can i do for launch a process from BMax.
I'm looking for commands like execFile or CreateProcess ?


klepto2(Posted 2005) [#2]
You can use this command : system_(command:String) eg: system_("notepad.exe")

Note: Your App will wait until the Process you've created is closed.


Bertrand(Posted 2005) [#3]
Thank's a lot, but where can i find information on this command?


Lomat(Posted 2005) [#4]
I have submitted a code archive entry that will allow your application to keep running in the background.

The down side is that its windows only :( (I'm trying to find a more cross platform way at the moment and have just got my hands on a mac and will also see if i can get the linux version working under FreeBSD soonish but in throey the max/linux process code should be the same.)


Bertrand(Posted 2005) [#5]
Really nice work! But, is it possible with your class to execute a command in 1 line and not 2. The software witch i use in remote can be launch(GUI) or execute(script)


JoshK(Posted 2006) [#6]
Any idea how to terminate the program? I would like to do it by sending a WM_CLOSE message to the program, so that is terminates "naturally" and safely. This doesn't seem to do it.

FindWindow() can be used to return the window and it works when I send the close message, but that is a really cheesy way of handling it...if you have more than one instance of the program running, it screws up.



TartanTangerine (was Indiepath)(Posted 2006) [#7]
If you created the process then you have the handle and the processID. You should then use an EnumWindows function to find the window and it's HWND based on that information.
EnumWindows((WNDENUMPROC)EmbedAppEnum, (LPARAM)AppProcessID);



JoshK(Posted 2006) [#8]
Okay, this adds a Kill() method to the process type. Run it in debug and watch the log. There's a "bad refs" error when the process ends.



SebHoll(Posted 2006) [#9]
Why don't you just use Skid's PUB.FreeProcess module (available via syncmods)? It's cross-platform, easy to use, and very adaptable...

Here's an example I've made to demonstrate how to use it...




Vertex(Posted 2006) [#10]
If there is any example to use the TStream extension? How can a process, in special a other bmax program, receive and send data to the master who create the process?

cu olli


jtfrench(Posted 2008) [#11]
Sorry if I'm just out of the loop, but can you let me know where this syncmods / Pub.FreeProcess stuff can be found? I'm looking for a cross-platform way to launch an external process and not have it block the parent process. I'm sure this has been covered somewhere, but I'm a bit confused about what syncmods is and where I can find a solution for it.

Thanks


Brucey(Posted 2008) [#12]
Isn't it in Pub?

mod/pub.mod/freeprocess.mod?


jtfrench(Posted 2008) [#13]
Indeed it is. Just found this now. I guess I just missed it since it doesn't appear in the Documentation part of the IDE. Are there any good docs on how to use freeprocess? Either way, it looks fairly easy so I can figure it out, but any good headstarts / documentation / wiki entries would be appreciated.


Brucey(Posted 2008) [#14]
It does appear to skimp on documentation somewhat (thanks Skid!).

Seb's little example above might help you get some ideas.