0

I am trying to learn a bit more of HTA and VBScript and I want to know if VBS allows to create dynamically functions as in JavaScript as:

var f = new Function('functionName', functionbody);

or

window['functionName'] = function() { functionbody };

Into the HTA, there is a <textarea> in witch the user writes its code as a string and I want to dynamically transform it into a VBScript function at runtime.

In other words, is there an equivalent of the new Function() constructor in HTA/VBScript that is available in JavaScript and of course without mixing JavaScript code with VBScript code into the same HTA file?

6
  • Be aware that HTA is strongly deprecated and the capability may be removed from Windows at any time. Microsoft is promoting Progressive Web Apps instead, and both Chrome and Edge have the capability of "installing" websites as "apps". Commented Aug 3, 2023 at 16:57
  • @JeffZeitlin not with VBScript though it should be mentioned. Commented Aug 3, 2023 at 17:16
  • 1
    Why not write the the HTA with JScript instead of VBScript? Commented Aug 3, 2023 at 21:54
  • @LesFerch I suppose because one has features that the other doesn't have and viceversa, but I don't know exactly because I am just learning a bit of both and trying to understand witch one is the best choice to use case by case. And usually I use js for html and vbs for hta because hta is run by mshta.exe that refers to ie engine and afaik it is not very good at running standard and up to date js as ES6. But I am not sure if such a way is the best possible and maybe it isn't: Just trying to learn by trial and mistake approach. Commented Aug 3, 2023 at 23:16
  • 1
    JScript is not modern JavaScript, but it's usually a better choice than VBScript in HTAs due to a few additional features and because it's less likely to have been uninstalled or disabled on any given machine. Here's the official documentation. Commented Aug 4, 2023 at 1:22

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.