WScript object not available when runing autostart script

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

Moderator: Gurus

WScript object not available when runing autostart script

Postby Dirk Braun » Sun Nov 13, 2005 11:01 am

Hi there,

I have encountered a problem wiht my startup script in MM.
It seems that the object for WScript is not available. I get a
error message that object WScript is not known.

After searching in this forum I only found some unprecise statement saying: "I think that there is some little thing like reintit wscript variable or something."

Can anyone help me with this?

How can I make WScript object available in MM startup scripts?

Thanks,
Dirk
Dirk Braun
 
Posts: 3
Joined: Sun Nov 13, 2005 10:54 am

Postby rovingcowboy » Mon Nov 14, 2005 1:16 am

this sounds like you can not use winscripts on your computer because you have that option turned off.

just where to turn it on at i can not remember but it is some place in the internet options either security or advanced tabs, i think it is there?

some one else might know for sure so keep looking for your answer here.

or go to http://help.lockergnome.com
and ask in that forum " how to turn on the use of windows scripting "

you will get lots of answers there because there is about 8 times the number of members in that forum, as there are in this forum.
8)
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 14149
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Postby onkel_enno » Mon Nov 14, 2005 2:09 am

@Dirk
What do you want to do with WScript exactly?
You'll have to use s.th. like
Code: Select all
Set WShell = CreateObject("WScript.Shell")
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx
onkel_enno
 
Posts: 2145
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany

Postby psyXonova » Mon Nov 14, 2005 5:24 am

Yes, as Onkel said this is the only WScript method available inside MMscripts.
You can use the Shell.Open or activate commands but not much else. If you wnat to use features like sleep etc, you should run them on an external vbs file which you will launch from the MMScript
psyXonova
 
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus

Postby Dirk Braun » Sun Nov 20, 2005 1:31 pm

well,

in that case, :roll: , to allow full wsh support, can someone give me an
example on how to call a subroutine or function in another VBScript file from a MM startup script file?

I tried it the following way:
Code: Select all
Set WShell = CreateObject("WScript.Shell")
Set  CallScript  = WShell.exec ("wscript /E:VBScript " & Chr(34) & "C:\myscript.vbs" & Chr(34))


and got an error message saying my file wouldn't be a script file. Though it is a VBScript file and just contains a WScript.Echo statement to test this out. Executing exaclty the same call in Windows CLI shell:
Code: Select all
wscript /E:VBScript "C:\myscript.vbs"

works fine.

Not even talking about possible function / subroutine calls towards the VBScript file - probably using ".arguments" method? :cry:

Any enlightening is most welcome :wink:
Dirk Braun
 
Posts: 3
Joined: Sun Nov 13, 2005 10:54 am

Postby Peke » Sun Nov 20, 2005 5:43 pm

OK here what some users and me found out few months ago:
'MM script executes Script.vbs'
Code: Select all
'==========================================================================
'
' NAME: Test VBScript Execution On MM Start
'
' AUTHOR: Peke
' DATE  : 13.04.2005
'
' COMMENT: Example How To Execute VBScript within MM Script
'
'==========================================================================

Sub OnStartup
  'make variables
  Dim WShell, Command, Result
 
  'Create Shell Object
  Set WShell = CreateObject("WScript.Shell")
'--------------------------------------------------------------------------
  'Set Shell command to execute first Script
  Command = Chr(34)&"Script1.vbs"&Chr(34)
 
  'Execute first script and report execution code in Result
  Result = WShell.Run(Command, 1, 1)
'--------------------------------------------------------------------------
 
  'If needed use Result to see if script is executed corectly
  'in case result is 0 all went OK
 
'--------------------------------------------------------------------------
  'Set Shell command to execute second Script
  Command = Chr(34)&"Script2.vbs"&Chr(34)

  'Execute second script and report execution code in Result
  Result = WShell.Run(Command, 1, 1)
'--------------------------------------------------------------------------
 
  'If needed use Result to see if script is executed corectly
  'in case result is 0 all went OK
 
End Sub


OK Put this script into MM auto Folder and it will be executed on MM startup. You can do what ever you want if you combine MM UI to assign script execution on desired command but basics are here. You can use arguments or whatever in starting script.

And Script1.vbs and script2.vbs looks Similar to this one:
Code: Select all
'==========================================================================
'
' NAME: Example Script
'
' AUTHOR: Peke
' DATE  : 13.04.2005
'
' COMMENT: This example inits basic MM Variable Needed or any external
'          VBScript executed outside MM(Command shell, Windows Explorer)
'          or within script as separate script.
'
' WARNING: MediaMonkey Needs to be started prior to execution of Script
'          if script is executed from Windows Explorer or command shell
'
'==========================================================================

'---< DO NOT DELETE THESE LINES FROM SCRIPT >------------------------------
'Define MM Default variable used within MM Scripting Language
Dim SDB

'Create Inits MM Object and Scripting Language
Set SDB = CreateObject( "SongsDB.SDBApplication")

'Set MM to Stay Started after Script execution
SDB.ShutdownAfterDisconnect = False

'---< DO NOT DELETE THESE LINES FROM SCRIPT >------------------------------
'---< Write Your own script below this line >------------------------------

'In This Script we will instruct MediaMonkey to skip to next track just for
'example instead of whole script you will write
SDB.Player.Next
I hope I have cleard something.

P.S. For command line and use of .arguments it will look like this:
Command = Chr(34)&"Script1.vbs"&Chr(34)&Chr(32)&Chr(34)"My Function"&Chr(34)
Best regards,
Pavle
MM Core Developer and Admin of free MediaMonkey extensions Hosting
Image
Image
Peke
 
Posts: 10432
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia

Postby Dirk Braun » Mon Nov 21, 2005 3:54 pm

Hi Peke,

thank you, I think this is exactly what I was looking for.

I'll try it out soon,

Ciao
Dirk Braun
 
Posts: 3
Joined: Sun Nov 13, 2005 10:54 am

Postby Peke » Mon Nov 21, 2005 4:42 pm

No problem, and welcome to community.
I know that we will see some interesting scripts from you.
Best regards,
Pavle
MM Core Developer and Admin of free MediaMonkey extensions Hosting
Image
Image
Peke
 
Posts: 10432
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia

Re:

Postby chrisjj » Sat Oct 22, 2016 7:44 am

11 years on... :)

'MM script executes Script.vbs'

I find on a portable install (EDIT: On Windows 7 64-bit) this failed with:

Image

and

Image

and (unrecognised vbscript error number)

Image

But with script1.vbs and script2.vbs content replaced by:

Code: Select all
MsgBox "hello"


it worked. Thanks.

I'd be interested to know how

Code: Select all
Command = Chr(34)&"Script1.vbs"&Chr(34)

is better than the more normal

Code: Select all
Command = """Script1.vbs"""

.
Chris
chrisjj
 
Posts: 4926
Joined: Wed Feb 14, 2007 5:14 pm
Location: UK

Re: WScript object not available when runing autostart scrip

Postby monkey hi fi » Sun Oct 23, 2016 11:47 pm

Might be something windows 10 related. I'm not sure though as I still have win 7. :D

Rovingcowboy /Keith hall /monkey hi fi
monkey hi fi
 

Re: WScript object not available when runing autostart scrip

Postby chrisjj » Mon Oct 24, 2016 5:11 am

monkey hi fi wrote:Might be something windows 10 related.


Those results were on Windows 7 64-bit.
Chris
chrisjj
 
Posts: 4926
Joined: Wed Feb 14, 2007 5:14 pm
Location: UK


Return to MediaMonkey 4 Addons developer forum

Who is online

Users browsing this forum: No registered users and 3 guests