How can you run an external file from within a patch?

genfu's icon

I'm trying essentially to do this:
have my patch run a file outside of the patch when you click a button. So for example I have a button that says "run [x] programme now" and it runs another file on the computer (in this case it is a .cmd file, but it would be also useful if i could do this to e.g. open a pdf file).

Is there a (preferably easy..) way to do this?

Advice appreciated

Mike S's icon

i think what you need is some kind of terminal/dos external

have a look at max objects

Guillaume Evrard's icon

hi,

you can use the following max message :

;max launchbrowser file:///path/to/any/file

g

Exit Only's icon

you might try the launchbrowser message. I use it to open applications from max.

Put something like this in a message box-

Note the escape slashes on the quotes. Obviously, use a path to the file you want to launch.

Here is a patch with the message box, just to be clear

Max Patch
Copy patch and select New From Clipboard in Max.

Exit Only's icon

Guillaume beat me to it!

genfu's icon

thanks for the replies

i can get it to open a pdf now like this:

;
max launchbrowser c:/quake/Atomizer_Live_Patch_2.5_Instructions.pdf

however, if i try and run a game .exe like this, it doesn't work (i immediately get an error from the game saying it couldn't load a certain file):

;
max launchbrowser c:/quake/fitzquake080.exe

and this message does nothing (not even an error):

;
max launchbrowser c:/quake/quakedelirium.cmd

can anybody clarify what is actually happening and why a pdf will run but not these .exe or .cmd files? and is there a simple way to get these kind of files to run, or do i need to look at java objects (if it's the latter an example would be really helpful)?

Guillaume Evrard's icon

i'm not sure you'll be able to launch executables this way.
the max message tells your system to open a file with the default application.

i don't really know what's going on in background with this message.

g

jan.jdo's icon

If the launchbrowser message doesn't work here is a java class that will launch an executable.

nice work with quake by the way!

genfu's icon

jan.jdo wrote on Sun, 07 June 2009 16:57If the launchbrowser message doesn't work here is a java class that will launch an executable.

nice work with quake by the way!

thanks will give that a go.

btw. sorry for the confusing cross posting, but did you see my post on the original thread about sending keystrokes here (i'm trying to get the quake patch into an application but i can't get your autobot.mxj to work in a collective or application...?):

genfu's icon

jan.jdo wrote on Sun, 07 June 2009 16:57If the launchbrowser message doesn't work here is a java class that will launch an executable.

nice work with quake by the way!

with this java class, what message do you send it to open a file which is in the same folder? for example it would be great if i can get this working in the quake patch, so you click a button within the patch to run the game... for this it needs to run:

quake_delirium.cmd

where that file is in the same folder as the patch application (but the whole file path cannot be specified).

can that be done with your java class?

jan.jdo's icon

you could find the path to your application in max then construct a full path to the quake file and use that with the launch message. something like:

Max Patch
Copy patch and select New From Clipboard in Max.

jan,.

Roman Thilenius's icon

genfu wrote on Sun, 07 June 2009 20:45
however, if i try and run a game .exe like this, it doesn't work (i immediately get an error from the game saying it couldn't load a certain file):

;
max launchbrowser c:/quake/fitzquake080.exe

and this message does nothing (not even an error):

;
max launchbrowser c:/quake/quakedelirium.cmd

can anybody clarify what is actually happening and why a pdf will run but not these .exe or .cmd files?

can it be that it has something to do with the
"helper apps" of your browser and/or system settings?

this would explain why it does not work on windows, where
propbably IE has taken control over the OS´s settings.

misho's icon

I'll add some more info to this since I've been doing some similar work lately, needing to run .exes from inside the patch. As others have pointed out, launching exes via the launchbrowser message does not work.

I was able to work around this, using simple Visual Basic scripts to execute shell commands.

So, from Max I send a (; max launchbrowser myOpenFileScript.vbs), then the vb script opens the file. You can't pass arguments this way, but probably fine if you're hard-coding exe paths.

The advantage over using a Java class is that all Windows systems have Visual Basic, but some may not have Java installed. A big plus when distributing standalones.