Forums > MaxMSP

How do I open an application from Max?

December 10, 2010 | 11:35 am

OS X 10.5.8

I’ve tried both [aka.shell] and [shell] by bill orcutt, running the command "open -a /Applications/Preview". Nothing happens. Thanks for any help.

Nevermind, figured out I need the .app extension.



pid
December 10, 2010 | 4:20 pm

;
max launchbrowser $1


January 24, 2012 | 5:07 am

and how appending a filename, e.g. to open a file in an external audio editor?

trying "C:/Program Files/cooledit/coolpro2.exe D:/samples/kick1.wav" works from XP command line, but it doesn´t work with launchbrowser (results in file not found-error message).


January 24, 2012 | 8:48 am

yes if the launchbrowser message would accept command line parameters a lot of hassle with shell externals and mxj would be gone. but there are ways..
i can not tell you much about MacOS but on windows you can execute .vbs (visual basic script) which can do very much, including "call another file with parameters".
what will look like this:

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
CmdLine1 = """C:Program Files123.exe"""
CmdLine2 = "-w"
CmdLine3 = """C:test it.wav"""
CmdLine4 = """D:Mucketest it_2.wav"""
CmdLine = CmdLine1 & " " & CmdLine2 & " " & CmdLine3 & " " & CmdLine4
oShell.run CmdLine,1,True
Set oShell = Nothing

a vbscript can also delete itself after executing
what’s cool about it: you can dynamically create and save scripts in a [text] object, execute them with launchbrowser
what’s not so cool: a filename in a script saved with max can sometimes pass the wrong characters to windows because the utf8 encoding. in this case another vbs can convert the current vbs to ANSI characters before it’s executed.
what i not know is if vbscripts might be disabled on a certain win-pc because of any security settings if not it is a way without external or mxj..
O.


January 24, 2012 | 10:09 am

Roll your own in Java perhaps (using Runtime.exec)?


January 24, 2012 | 10:13 am

i never did java, sorry.

but that vsb thing worked out, mommalovin’ thanks olsen!

though it will be easier to make good old dos batch, max doesn´t like those "" things.

`

– Pasted Max Patch, click to expand. –

January 24, 2012 | 11:31 am

max seems not to execute a batch file. [text] (not [textedit]) doesn’t care so much about "" and There’s no need to exit things. but in the messages to [text].

e.g. this: CmdLine1 = """C:Program Files123.exe"""
is this in a message: "CmdLine1 = """C:\Program Files\123.exe""""

Here’s a snippet for the self deletion http://www.bytemycode.com/snippets/snippet/426/

but that’s all not easy enough, i’m currently trying to build a little shell external or at least execution external for win. but as these are my first steps in C, i better not share it at the moment until i know what i’m doing..
O.

EDIT: sorry i was wrong with the batch files, max CAN execute them with launchbrowser, there you go, even easier than vbs :)
O.


January 24, 2012 | 11:43 am

yes the patch i´ve posted works with using the batch (at least on xp and max5).

but thanks for the hint on using slashes!


January 24, 2012 | 12:20 pm

this could still not work if you use a file/path with strange characters in the batch.
because win doesn’t use utf8 encoding on it’s filesystem but max converts it,i think.
as you see here i was struggeling with it http://cycling74.com/forums/topic.php?id=31813

so if you come across this problem add the line "chcp 65001" at the beginning of your batch may help, BUT only on win7,
this command definitely does not work in a batch on xp. that’s why i went with vbs
back then which can also convert to ANSI on both winversion.
this is out of interesst of most people? sorry this was spinning around in my head for weeks back then. ;)


Viewing 9 posts - 1 through 9 (of 9 total)