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

Jun 7, 2009 at 3:39pm

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

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

#44279
Jun 7, 2009 at 3:41pm

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

have a look at max objects

#159200
Jun 7, 2009 at 4:44pm

hi,

you can use the following max message :

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

g

#159201
Jun 7, 2009 at 4:44pm

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

Put something like this in a message box-

;
max launchbrowser “file:///Applications/MonomeSerial.app

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

– Pasted Max Patch, click to expand. –
#159202
Jun 7, 2009 at 6:36pm

Guillaume beat me to it!

#159203
Jun 7, 2009 at 6:45pm

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)?

#159204
Jun 7, 2009 at 7:03pm

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

#159205
Jun 7, 2009 at 10:57pm

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

nice work with quake by the way!

#159206
Jun 7, 2009 at 11:09pm
jan.jdo wrote on Sun, 07 June 2009 16:57
If 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…?):

http://www.cycling74.com/forums/index.php?t=msg&th=37895&start=0&rid=6363&S=4d6474ee1c8b5e13b04aeba2b2fb24f6

#159207
Jun 15, 2009 at 12:13pm
jan.jdo wrote on Sun, 07 June 2009 16:57
If 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?

#159208
Jun 15, 2009 at 8:57pm

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:

– Pasted Max Patch, click to expand. –

jan,.

#159209
Jun 16, 2009 at 5:36am
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.

#159210
Dec 3, 2012 at 4:00am

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.

#159211

You must be logged in to reply to this topic.