Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #12037

Re: VBScript & JScript cross language execution?

From Roger <rog6@somewwhere961.com>
Newsgroups microsoft.public.scripting.vbscript
Subject Re: VBScript & JScript cross language execution?
Date 2019-01-14 13:18 +0000
Organization A noiseless patient Spider
Message-ID <q1i26g$su0$1@dont-email.me> (permalink)
References <1hcey7cr7f5uv$.hq9gp8ozljcq.dlg@40tude.net>

Show all headers | View raw


On Wed, 09 Jan 2019 22:05:52 +0700, JJ wrote:

> 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.

JScript in VBScript...

Option Explicit

dim ojs

set ojs= createobject("ScriptControl")
ojs.language = "JScript"

ojs.AddCode "function x(a,b) {return 'answer = ' +(a+b);}"

msgbox(ojs.Run("x",1,2))



You might need to register the control (32 bit)

%windir%\SysWoW64\regsvr32.exe %windir%\SysWoW64\msscript.ocx

And you'll need to run it as 32 bit

%windir%\SysWoW64\cscript.exe  whatever.vbs


Running VBScript in JScript?  Tricky, it would depend on how you are 
running the JScript, you'd probably need IE.


I've used the above method to run VBScript in other programming languages.
For instance, VFP6 calls VBScript, which then uses .Net to create a SHA256 
hash.

objvb.language = "VBScript"

(The following needs to be on one line)

objvb.addcode('function fnh(x,y):
dim e,c,h:set e=createobject("System.Text.UTF8Encoding"):
set c=createobject("System.Security.Cryptography.HMACSHA256"):
c.Key=e.GetBytes_4(x):
h=c.ComputeHash_2(e.GetBytes_4(y)):
fnh=h: 
end function ')

Called with...
hash = objvb.run("fnh", key, text)

Similarly VFP6 has trouble with binary streams downloaded from the 
internet, but VBScript can download and save the file, without VFP6 ever 
being aware.

objvb.addcode('function fnk(ohttp,f):
dim e:
set e=CreateObject("ADODB.Stream"):
e.type=1:
e.open:
e.write ohttp.ResponseBody:
e.savetofile f, 2:
set e = nothing:
end function ')

Called with...
objvb.run("fnk", httpobject, filename)


Roger

Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

VBScript & JScript cross language execution? JJ <jj4public@vfemail.net> - 2019-01-09 22:05 +0700
  Re: VBScript & JScript cross language execution? JJ <jj4public@vfemail.net> - 2019-01-09 22:09 +0700
    Re: VBScript & JScript cross language execution? "Mayayana" <mayayana@invalid.nospam> - 2019-01-09 10:22 -0500
    Re: VBScript & JScript cross language execution? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-01-09 19:06 +0100
      Re: VBScript & JScript cross language execution? "Mayayana" <mayayana@invalid.nospam> - 2019-01-09 13:22 -0500
        Re: VBScript & JScript cross language execution? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-01-09 19:46 +0100
          Re: VBScript & JScript cross language execution? "Mayayana" <mayayana@invalid.nospam> - 2019-01-09 15:49 -0500
            Re: VBScript & JScript cross language execution? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-01-09 22:36 +0100
      Re: VBScript & JScript cross language execution? JJ <jj4public@vfemail.net> - 2019-01-10 22:56 +0700
  Re: VBScript & JScript cross language execution? Roger <rog6@somewwhere961.com> - 2019-01-14 13:18 +0000
    Re: VBScript & JScript cross language execution? JJ <jj4public@vfemail.net> - 2019-01-15 05:31 +0700
      Re: VBScript & JScript cross language execution? Roger <rog6@somewwhere961.com> - 2019-01-16 17:34 +0000

csiph-web