How to shutdown MM with script

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

MyVikes
Posts: 89
Joined: Sun Jul 02, 2017 1:20 am

How to shutdown MM with script

Post by MyVikes »

I know the thread here ( http://www.mediamonkey.com/forum/viewto ... 15#p241015 ) is 10 years old but I need to be able to shutdown MM4 via a script (or external program) and the simple script below isn't working. I've verified no instances of MM4 are already running including the service and the SDBApplication::ShutdownAfterDisconnect is still referenced in the documentation ( https://www.mediamonkey.com/wiki/index. ... Disconnect ). I've tried this in a .vbs and Windows Application and MM4 will start but not shutdown.

Should this still work or am I missing something else i need to set perhaps in the MM4 Options or elsewhere?

Code: Select all

Dim SDB 
Set SDB = CreateObject( "SongsDB.SDBApplication") 
SDB.ShutdownAfterDisconnect = True


' put the above code in a vbs file called ShutdownMM.vbs file
'set it to run at a certian time in the task scheduler.
'it will stop all media monkey fuctions at once when ran.  so give it a minute to finish mm fuctions.
'it can be run by a shortcut also.
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: How to shutdown MM with script

Post by Peke »

Try with:

Code: Select all

din x
Dim SDB 
Set SDB = CreateObject( "SongsDB.SDBApplication") 
set x = SDB.IsRunning
Do While not x
  SDB.ProcessMessages
  x = SDB.IsRunning
Loop
SDB.ShutdownAfterDisconnect = True
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
MyVikes
Posts: 89
Joined: Sun Jul 02, 2017 1:20 am

Re: How to shutdown MM with script

Post by MyVikes »

After fixing a couple of typo's :D i ran the script and i get "Microsoft VBScript runtime error: Object required: 'IsRunning'" with MM4 running or not on the line "Set x = SDB.IsRunning"

I had tried a variation of what you're suggesting as follows:

Code: Select all

Dim SDB 

Set SDB = CreateObject( "SongsDB.SDBApplication") 

Wscript.Echo ("SDB IsRunning before loop :" & SDB.IsRunning)

Do While Not SDB.IsRunning
	Wscript.Echo ("SDB IsRunning in loop    :" & SDB.IsRunning)

	SDB.ProcessMessages
Loop

Wscript.Echo ("SDB IsRunning after loop  :" & SDB.IsRunning)

SDB.ProcessMessages

Wscript.Echo ("SDB IsRunning after PM    :" & SDB.IsRunning)

SDB.ShutdownAfterDisconnect = False

Wscript.Echo ("SDB SAD should be False   :" & SDB.ShutdownAfterDisconnect)

SDB.ShutdownAfterDisconnect = True

Wscript.Echo ("SDB IsRunning after SAD   :" & SDB.IsRunning)

Wscript.Echo ("SDB SAD2 should be True   :" & SDB.ShutdownAfterDisconnect)
and i get the following:

SDB IsRunning before loop :True
SDB IsRunning after loop :True
SDB IsRunning after PM :True
SDB SAD should be False :False
SDB IsRunning after SAD :True
SDB SAD2 should be True :True


So in summary, i can start MM4, get the IsRunning status and set ShutdownAfterDisconnect but it does not shutdown MM4. BTW, i've tried this on my primary MM4 PC and a development laptop.

Still no luck shutting down MM4 from a script. :-?
Post Reply