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
i think what you need is some kind of terminal/dos external
have a look at max objects
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
Guillaume beat me to it!
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)?
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
If the launchbrowser message doesn't work here is a java class that will launch an executable.
nice work with quake by the way!
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...?):
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?
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:
jan,.
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.
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.