WScript object not available when runing autostart script

Rispondi al messaggio

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

BBCode attivo
[img] attivo
[url] attivo
Emoticon attive

Revisione argomento
   

Espandi visuale Revisione argomento: WScript object not available when runing autostart script

Re: WScript object not available when runing autostart scrip

da chrisjj » lun ott 24, 2016 5:11 am

monkey hi fi ha scritto:Might be something windows 10 related.
Those results were on Windows 7 64-bit.

Re: WScript object not available when runing autostart scrip

da monkey hi fi » dom ott 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

Re:

da chrisjj » sab ott 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:

Immagine

and

Immagine

and (unrecognised vbscript error number)

Immagine

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

Codice: Seleziona tutto

MsgBox "hello"
it worked. Thanks.

I'd be interested to know how

Codice: Seleziona tutto

Command = Chr(34)&"Script1.vbs"&Chr(34)
is better than the more normal

Codice: Seleziona tutto

Command = """Script1.vbs"""
.

da Peke » lun nov 21, 2005 4:42 pm

No problem, and welcome to community.
I know that we will see some interesting scripts from you.

da Dirk Braun » lun 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

da Peke » dom nov 20, 2005 5:43 pm

OK here what some users and me found out few months ago:
'MM script executes Script.vbs'

Codice: Seleziona tutto

'==========================================================================
'
' 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:

Codice: Seleziona tutto

'==========================================================================
'
' 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)

da Dirk Braun » dom 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:

Codice: Seleziona tutto

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:

Codice: Seleziona tutto

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:

da psyXonova » lun 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

da onkel_enno » lun nov 14, 2005 2:09 am

@Dirk
What do you want to do with WScript exactly?
You'll have to use s.th. like

Codice: Seleziona tutto

Set WShell = CreateObject("WScript.Shell")

da rovingcowboy » lun 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)

WScript object not available when runing autostart script

da Dirk Braun » dom 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

Top