Discussion:
VBScript & JScript cross language execution?
(too old to reply)
JJ
2019-01-09 15:05:52 UTC
Permalink
Any way or trick to execute JScript code from VBScript code in a VBS file,
or execute VBScript code from JScript code in a JS file?

FYI, I already know about VBScript & JScript cross language execution via
HTML, HTA, and WSF files. I want to know if it's also possible from a VBS or
JS file.
JJ
2019-01-09 15:09:19 UTC
Permalink
Post by JJ
Any way or trick to execute JScript code from VBScript code in a VBS file,
or execute VBScript code from JScript code in a JS file?
FYI, I already know about VBScript & JScript cross language execution via
HTML, HTA, and WSF files. I want to know if it's also possible from a VBS or
JS file.
And I don't mean to execute the other language by executing a different file
type. e.g. run "cscript.exe thecode.js" from VBScript. But to actually call
a function provided from the other language.
Mayayana
2019-01-09 15:22:00 UTC
Permalink
"JJ" <***@vfemail.net> wrote

| And I don't mean to execute the other language by executing a different
file
| type. e.g. run "cscript.exe thecode.js" from VBScript. But to actually
call
| a function provided from the other language.

I'd be very surprised. They're two different
interpreters. If you run from within VBS it will
be interpreted as VBS and the js will error.
In fact, there are various interpreters. A browser
script interpreter won't be the same as WSH
interpreter. And built-in objects are different.
There's no wscript global object in a webpage
and no document global object in a .vbs or .js
file.

There are methods like Eval and ExecuteGlobal,
but none of those seems to have a language
parameter.

It sounds like you want a method in one that
only exists in the other. Maybe the better question
would be how to accomplish what you need?
Evertjan.
2019-01-09 18:06:51 UTC
Permalink
Post by JJ
Post by JJ
Any way or trick to execute JScript code from VBScript code in a VBS
file, or execute VBScript code from JScript code in a JS file?
FYI, I already know about VBScript & JScript cross language execution
via HTML, HTA, and WSF files. I want to know if it's also possible from
a VBS or JS file.
And I don't mean to execute the other language by executing a different
file type. e.g. run "cscript.exe thecode.js" from VBScript. But to
actually call a function provided from the other language.
This is nonsense, as text-files containing a script in VBS or JS or any
other scripting language cannot execute by themselves.

You will have to use a scripting engine, and "give" that engine the content
of such file to execute.

========

Now, most modern browsers will execute a text-file or text-stream with JS in
it, [and Microsoft's old and defunct browser will also execute VBS.]

========

Some web-servers, notably Windows-server, will execute files with JS [in an
old form, called "jscript"] or VBS in it, before sending the resulting
stream to the client browser.

The engine that will do both, and will execute functions defined in the
other language is the ASP-engine.

So here you can make a JS-function and execute it in the VBS-code as were it
a VBS-function. The extension that accepts such a file is usualy .asp, but
you can programme the server engine to accept any other extension, like
.html or .xyz3.

======

VBS and JS can be executed on a windows machine by the Cscript/Jscript-
engine, but not both at the same time.

======

A large number of other programmes can execute some version of JS.

======

[btw,
VB and VBA are related, but other languages thsn VBS
and are o.t. in this NG. JS as such is o.t. too]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mayayana
2019-01-09 18:22:42 UTC
Permalink
"Evertjan." <***@inter.nl.net> wrote

| [btw,
| VB and VBA are related, but other languages thsn VBS
| and are o.t. in this NG. JS as such is o.t. too]
|

A WSF is a Windows Script file. In other words,
he only asked about running js from vbs. VB never
came into it.
Evertjan.
2019-01-09 18:46:24 UTC
Permalink
Post by Mayayana
| [btw,
| VB and VBA are related, but other languages thsn VBS
| and are o.t. in this NG. JS as such is o.t. too]
|
A WSF is a Windows Script file. In other words,
he only asked about running js from vbs. VB never
came into it.
That's where "btw" is for,
and btw,
this is a usenet NG, not a helpdesk.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mayayana
2019-01-09 20:49:17 UTC
Permalink
"Evertjan." <***@inter.nl.net> wrote

| That's where "btw" is for,
| and btw,
| this is a usenet NG, not a helpdesk.
|

Oh, goodie. Could you direct me to linens and
towels? I keep getting lost in the bath fixtures
section. :)
Evertjan.
2019-01-09 21:36:20 UTC
Permalink
Post by Mayayana
| That's where "btw" is for,
| and btw,
| this is a usenet NG, not a helpdesk.
|
Oh, goodie. Could you direct me to linens and
towels? I keep getting lost in the bath fixtures
section. :)
Well, we are here to teach you, if you stay on topic,
you think you need it, and it is not just lazyness.

A pity you don't sign.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
JJ
2019-01-10 15:56:30 UTC
Permalink
Post by Evertjan.
This is nonsense, as text-files containing a script in VBS or JS or any
other scripting language cannot execute by themselves.
You will have to use a scripting engine, and "give" that engine the content
of such file to execute.
I'm well aware of that. I'm not expecting JScript code to exist and be
runnable from within a VBS file. What I want is something like what WSF
does. i.e. each JScript and VBScript code, although they're in the same
file, they're contained in an XML element, and executed with their
respective engine. However, both can cal each other's public function, IIRC
access each other's global variables.
Roger
2019-01-14 13:18:09 UTC
Permalink
This post might be inappropriate. Click to display it.
JJ
2019-01-14 22:31:03 UTC
Permalink
This post might be inappropriate. Click to display it.
Roger
2019-01-16 17:34:00 UTC
Permalink
Post by JJ
So, does this means that VBScript (and probably VB too) built in
functions/constants are not stored in the global module, but a hidden
module which are always accessible from all modules? i.e. in a true
global module, but hidden.
I don't know. I generally don't use the constants, but instead use the
actual value, when one language is writing a program to run in another.

Similarly, overloaded functions and methods can be a problem, and I
frequently mess up when trying to add comments, line continuations, etc.

Roger

Loading...