1

OS: windows 10
Node: v6.9.4
iTunes 12.5.5.5

I'm trying to write a node.js app that communicates with itunes, it will do a lot of things and i want to capture the response and show in a web page.

what i'm trying to do right now to understand this wscript thing is run a node file, that it will keep running to output on the 'change song' event some info about the tack.

After i did some research i made to a point, but now i'm stuck. I have no knowledge on windows ecosystem coding and is in this part that i'm struggling

searching the web i found this solution.

i don't find why i can on cmd use cscript o wscript but inside the .js file i need to use wscript

/* itunes open and playing a song */
var itunes = WScript.CreateObject("iTunes.Application");

var currentTrack = itunes.CurrentTrack;

WScript.Echo("name: " + currentTrack.Name + " artist: " + currentTrack.Artist);

open a cmd, go to that folder, and run

cscript /nologo myItunesScript.js 
/* /nologo prevent to show some default cmd text*/

the program will run, output the music playing and it will close itself

If i do the same thing with wscript i don't know why but it show a popup window with the result instead of showing on the cmd screen.

On this page http://www.joshkunz.com/iTunesControl/main.html show a lot of things that i can do and even work with events.

I didn't find any app on npm that does some magic and makes my life easier.

So if someone can give some north, i will appreciate a lot.

EDIT: It is possible to connect to "iTunes.Application" without WScript from node?
If don't, is possible to listen for events from the output o WScript? (like in socket.io, you connect to someting and keep listening for things)

1
  • cscript.exe is the command line version of the WSH (Windows Scripting Host) while wscript.exe is the GUI version. They are one and the same thing, just with different output. Example the code WScript.Echo "Hello" in cscript.exe will output to the command line while the same line executed with wscript.exe will output to a popup message. Commented Jan 28, 2017 at 10:07

1 Answer 1

2

The question isn't clear I probably shouldn't of answered.
This answer specifically address this from the question;

If i do the same thing with wscript i don't know why but it show a popup window with the result instead of showing on the cmd screen.

You may be confusing what cscript.exe and wscript.exe are.

Both programs are the WSH (Windows Script Host, also confusingly known as WScript).

  • cscript.exe - The command line version
  • wscript.exe - The Windows GUI version

Both run VBScript but output the results differently, here is a simple example to demonstrate.

The following script will output the phrase Hello World;

Dim output: output = "Hello World"
WScript.Echo output

Using cscript.exe the output is;

>cscript //nologo "test.vbs"
Hello World

Using wscript.exe the output is;

>wscript //nologo "test.vbs"

Popup WScript Window

Sign up to request clarification or add additional context in comments.

3 Comments

ok, but can you give me a example on how to run from node and keep runing to listen for events.
@MateusSilva if that is what you intentionally meant to ask try updating the question, at the moment it doesn't say anything like that. I simply tried to answer "If i do the same thing with wscript i don't know why but it show a popup window with the result instead of showing on the cmd screen.", which I have done.
its on the question "what i'm trying to do right now to understand this wscript thing is run a node file, that it will keep running to output on the 'change song' event some info about the track."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.