JJ Commands, Command Line, Scripts and More

So I had a question from a user the other day asking how they could configure Jukebox Jockey to run a media scan at startup.  This can be useful if you are regularly updating your media or use some automated process to update the media of a remote system and need to ensure that Jukebox Jockey's view of your media is always up to date (well, at least after a restart of JJ).

The fact is that there are no specific settings inside of JJ to allow for this, we do provide access to Jukebox Jockey's commands so that you can achieve this.  When I use the word "command" I am generally talking about the commands available in the "Assign User Commands" configuration screens of JJ.

Before I discuss how to run a scan at startup, let me first discuss how commands can be run without having a user click a button.  For users of all editions of Jukebox Jockey (Home, Gold & Platinum) you can use the command line or a script/executable that talks to JJ's COM interface.  For Platinum users there is also the scheduler, which enables you to run commands when specific events occur inside JJ or at a specific time of the day.  Commands consist of the name of the command and possibly some required and/or optional parameters.

The Jukebox Jockey command line
This is the easiest way to make JJ run a command. You can run a Jukebox Jockey command line while starting JJ, or even if JJ is already running.  If it's already running then the command is simlpy forwarded on to the instance of JJ that is running.  Each edition of JJ has a different name for the executable, I am just going to refer to it here as JJ.exe.  So a simple command line to make JJ skip to the next track would be:

JJ.exe /command=next

a more complext command line including parameters is:

JJ.exe command=rescan full=0 showprompt=0 allowcancel=0

The command above being the one that you would use to force JJ to run a scan.  /full=0 tells JJ to only scan for new and modified tracks, /showprompt=0 tells JJ not to config the scan, just go ahead and do it, /allowcancel=0 tells JJ to not allow a user to cancel the scan while it is running.

That's it, using this technique you can modify a shortcut to make JJ run a command at startup, create shortcuts or batch files to make JJ run commands while it is already running.

The Jukebox Jockey COM interface 
COM (in this instance) standards for (Microsoft's) Component Object Model.  If you really keen to know what it is you can read some more here (Microsoft COM) but for our purposes it simply means that other programs can talk to JJ to run it's commands and get information from it.  An exmaple is Jukebox Jockey's home screen.  It uses COM to all the scripts in it's web page to communicate back to the main Jukebox Jockey code via the embedded Internet Explorer control.  I won't go into it too much depth here, but by all means if you have a question then ask away. The COM interface provides many advantages over the command line interface.  If all you want to do is tell JJ to run a single command, then the command line may be the way to go, but if you need a script or some code to ask JJ for information and make decisions based on that information, then the COM interface is what you need.

A really simple example of using the COM interface is a Javascript script.

1. create a text file and call it "jjscan.js" (you can save this anywhere on your PC)

2. Insert these 2 lines in your script file:
var jj=new ActiveXObject("JukeboxJockey.JJApp");
jj.execCmd('rescan','full=0 showprompt=0 allowcancel=0');

3. Make sure Jukebox Jockey is running

4. Run (double-click) jjscan.js

Notice that the paramets to execCmd are very similar to the command line?  There's a good reason for that ;-)

There are many programming languages the support using COM automation via a similar call to something like "new ActiveXObject".  Other languages (including .Net) allow you to import JJ's Type Library so that you can code against it.

Here is a link to the current version of the command reference.  This is a work in progress, but covers the most used commands.  It is actually generated using a script similar to the one above, by telling JJ to export it's command line to an XML file.

jjcommandreference.zip

So, to address the initial problem of running a scan at startup.  You can see that you can do it from a command line, so you can modify a shortcut or batch file to start JJ like that.

If you have JJ Platinum you can add a schedule for the "ON_SYSTEM_START" event to run a rescan. You can also create a text file, name it "StartupScript.txt" and add the following line to it:

rescan Full=0 ShowPrompt=0 AllowCancel=0

The edit settings.ini and add the following:

[Settings]
...
StartupScript=[PathTo]\StartupScript.txt

I haven't discussed the scripts, until just now.  They are simply another way to run commands.  It simply allows you to run a sequence of commands, you can include as many as you like in a single file.  The ability to run one at startup is only available in the Platinum edition of Jukebox Jockey.  However there is a command that can be run:

JJ.exe command=execscript filename="[PathTo]\Script.txt"

In general though there are better ways (as outlined above) to achieve the same thing.

Copyright 2015 Jukebox Jockey, LLC