MD Launch from command line and launch parameters

Stuart Beesley (Mr Toolbox)'s Avatar

Stuart Beesley (Mr Toolbox)

02 Nov, 2023 04:21 PM

A reminder that you can launch Moneydance from the command line... The below are Mac terminal commands, but can be adjusted for Windows / linux:.

Basic launch command:

/Applications/Moneydance.app/Contents/MacOS/Moneydance

Parameters - all optional

-d                   turns on MD DEBUG mode
-v                   prints the current version
-nobackup            disables backups for this MD session (from MD2023.2 ALPHA build 5047 onwards)
datasetname          will open specified dataset - specify the full path wrapped in "quotes". NOTE: quotes must be plain text format
pythonscriptname.py  adds script to a list of scripts to execute (but this seems to then be ignored)
importfilename       executes file import (mutually exclusive to datasetname option)
-invoke_and_quit=x   will pass along a string that you can use to invoke an 'fmodule' (extension) and quit (not showing UI)
                     executes Main.showURL(invokeAndQuitURI)
                     e.g. 'moneydance:fmodule:test:test:customevent:magic'
                     (e.g. my own extension with an id of test defines it's own command called 'test:customevent:magic'
                     (there are other variations of this parameter and with ? instead of ':' for parameters.....
-invoke=x            Same as -invoke_and_quit but does launch the UI first and doesn't quit...!

NOTE: extensions need to be designed to understand the -invoke parameters... Some use -invoke and perform their own quit after execution (i.e. not the -invoke_and_quit option.

MD2021.2(3088) adds the capability to set the encryption passphrase into an environment variable to bypass the popup password question. Use either:

md_passphrase=

or

md_passphrase_[filename in lowercase format]=

The shell command to set is as follows (where x=password):

export md_passphrase=x

Extensions:
Two extensions have been updated to leverage the =invoke command. These are: Quote Loader & Extract Data. The commands to use these are:

-invoke=moneydance:fmodule:securityquoteload:runstandalone:quit
-invoke=moneydance:fmodule:extract_data:autoextract:quit

You can only use one of these at a time. Replace 'quit' with 'noquit' to leave the MD session running after execution.

An example using all these parameters is as follows:

/Applications/Moneydance.app/Contents/MacOS/Moneydance -d -nobackup "/Users/xxx/Library/Containers/com.infinitekind.MoneydanceOSX/Data/Documents/moneydance_dataset_example.moneydance" -invoke=moneydance:fmodule:extract_data:autoextract:quit

Perhaps everyone using these launch parameters can post their experience(s), tips, etc here....

  1. 1 Posted by Pete Chalmers on 10 Dec, 2023 12:49 AM

    Pete Chalmers's Avatar

    I have been trying to get MD to output the version number on the command line (so I can capture it for use in a script) without success, so I was pleased to find this article However, I'm on Windows11 and I've tried both -v and /v (both upper and lower case, even though I'm sure it shouldn't matter) and haven't got the result I'm looking for.
    -v seems to do nothing, while /v opens the "Welcome to Moneydance" window, which *does* have the version on it but not in a 'scriptable' way!
    Am I missing something, or am I out of luck?
    In passing, some other applications have the version number available through the VersionInfo properties of the executable file itself - that's not the case for MoneyDance at present, but could it be considered for the future?

    Thanks.

  2. 2 Posted by Stuart Beesley ... on 10 Dec, 2023 01:34 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    That is super odd.. Me too on Windows. I suspect that it is working and outputting to stderr (which you can't see). But I can't be sure... Too late to play with it now tho'

    Unless you know how to capture stderr?

    You could try executing the moneydance.jar file via java and the -v command..?

    @Derek @dwg any ideas? Thx

  3. 3 Posted by dwg on 10 Dec, 2023 03:09 AM

    dwg's Avatar

    I have doubts that Moneydance is writing anything externally I have not been able to get anything from StdErr or StdOut, it is not writing anything to the Moneydance Error log.

    "command" 2> "filename" writes error message to filename

  4. 4 Posted by Pete Chalmers on 10 Dec, 2023 01:48 PM

    Pete Chalmers's Avatar

    Just tried the stderr redirect and the output file is empty.

    I can't work out how to run the .jar file - I don't have Java installed independently and don't really want to do that just for this :-)

    Thanks for the replies though.

  5. 5 Posted by Stuart Beesley ... on 10 Dec, 2023 04:46 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Try this:

    java -jar /Applications/Moneydance.app/Contents/Java/moneydance.jar -v

    (see if you have any java installed at all)

    There should also be (probably) a java.exe file in your Moneydance App folder? Yes/No?

  6. 6 Posted by Pete Chalmers on 10 Dec, 2023 05:28 PM

    Pete Chalmers's Avatar

    Ah-ha!! After a couple of false starts I got there.
    On windows I have:
    C:\Program Files\Moneydance\jre\bin\java.exe and
    C:\Program Files\Moneydance\lib\moneydance.jar
    So with full paths omitted for clarity, and running in a powershell terminal:
    PS C:\> & "jave.exe" -jar "moneydance.jar" -v
    Moneydance 2023.3 (5064)

    (false starts were before I tried the '&' to invoke the command within powershell)

    Brilliant, thanks very much. Not the most obvious of ways to get a version number :-), but it does what I want!

  7. 7 Posted by Stuart Beesley ... on 10 Dec, 2023 06:17 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    I’m wondering if install4J is swallowing the -v. Can you try again with
    --version

    ?

  8. 8 Posted by Stuart Beesley ... on 10 Dec, 2023 09:05 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    OK, this actually does work too:

    Moneydance -v > outputfile.txt 2>&1

    so the -v is working, and going to stderr. The above redirects stderr to stdout and then you redirect stdout to a file...

  9. 9 Posted by Stuart Beesley ... on 10 Dec, 2023 09:19 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    FYI - I have now built my own knowledge of all these launch settings into toolbox.. Could you try and give me your opinion?

    PREVIEW
    https://yogi1967.github.io/MoneydancePythonScripts/

    Advanced Menu > 'Show Advanced MD Launch options/parameters'

    Thanks

  10. System closed this discussion on 10 Mar, 2024 09:20 PM.

  11. Stuart Beesley (Mr Toolbox) re-opened this discussion on 30 Apr, 2024 08:19 PM

  12. 10 Posted by Stuart Beesley ... on 30 Apr, 2024 08:19 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    On a Mac you can add:

    -d &> outputfile.txt
    

    to redirect the MD launch output to a file too

  13. System closed this discussion on 30 Jul, 2024 08:20 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac