Page 1 of 1

WScript object not available when runing autostart script

Posted: Sun Nov 13, 2005 11:01 am
by Dirk Braun
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

Posted: Mon Nov 14, 2005 1:16 am
by rovingcowboy
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)

Posted: Mon Nov 14, 2005 2:09 am
by onkel_enno
@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")

Posted: Mon Nov 14, 2005 5:24 am
by psyXonova
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

Posted: Sun Nov 20, 2005 1:31 pm
by Dirk Braun
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:

Posted: Sun Nov 20, 2005 5:43 pm
by Peke
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)

Posted: Mon Nov 21, 2005 3:54 pm
by Dirk Braun
Hi Peke,

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

I'll try it out soon,

Ciao

Posted: Mon Nov 21, 2005 4:42 pm
by Peke
No problem, and welcome to community.
I know that we will see some interesting scripts from you.

Re:

Posted: Sat Oct 22, 2016 7:44 am
by chrisjj
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"""
.

Re: WScript object not available when runing autostart scrip

Posted: Sun Oct 23, 2016 11:47 pm
by monkey hi fi
Might be something windows 10 related. I'm not sure though as I still have win 7. :D

Rovingcowboy /Keith hall /monkey hi fi

Re: WScript object not available when runing autostart scrip

Posted: Mon Oct 24, 2016 5:11 am
by chrisjj
monkey hi fi wrote:Might be something windows 10 related.
Those results were on Windows 7 64-bit.