How to shutdown MM with script

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: How to shutdown MM with script

Re: How to shutdown MM with script

by MyVikes » Mon May 04, 2020 4:11 am

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. :-?

Re: How to shutdown MM with script

by Peke » Sun May 03, 2020 9:41 am

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

How to shutdown MM with script

by MyVikes » Sun May 03, 2020 3:41 am

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.

Top