Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open source mshta.exe #533

Closed
DBJDBJ opened this issue Oct 14, 2020 · 57 comments
Closed

Open source mshta.exe #533

DBJDBJ opened this issue Oct 14, 2020 · 57 comments

Comments

@DBJDBJ
Copy link

DBJDBJ commented Oct 14, 2020

Why is nobody talking HTA here?

@champnic
Copy link
Member

This repo is specifically about the WebView2 control. Did you have an ask about WebView2 related to HTA/mshta.exe?

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 14, 2020

@champnic thanks Nic, yes I did ... somehow I led myself to believe "this" will replace "that" in a near future?
I assume one could build relatively easily the same little thing based on this WebView2 usage.

@champnic
Copy link
Member

Gotcha! WebView2 is certainly a migration path forwards, but isn't currently an entire framework in and of itself, like Electron. I actually think PWAs are probably the more obvious path forwards for HTAs. If you'd like I can add this as a feature request on our backlog, but my feeling is we probably wouldn't get to this for a while (if ever).

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

@champnic, I might require too much of a cognitive effort to follow your good reply. mshta.exe was/is written by using IE related WebView2 control, still in existence on Win10,8,7. One has to see it and use it to fully appreciate it. Attached.

powerof.zip

Now, who do I ask to open source that mshta.exe ?

@ukandrewc
Copy link

HTA is just a webbrowser control in a window, I'd say you shouldn't need to move to PWA.

It seems like it would be easier to use WebView2 on your own form, and use the HTML you already have, without the HTA tags.

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

HTA is just a webbrowser control in a window, I'd say you shouldn't need to move to PWA.

Wholeheartedly agree

It seems like it would be easier to use WebView2 on your own form, and use the HTML you already have, without the HTA tags.

Forgive me, I am not sure I follow. Where do I put that form?

@ukandrewc
Copy link

ukandrewc commented Oct 15, 2020

How do you code your HTAs as the moment and are they in JS or VBS?

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

Please look into the zip attached above : powerof.zip

JavaScript, CSS, BootStrap, jQuery, embedded images. All in one HTA. There are no includes.

@ukandrewc
Copy link

I would but it's expired ;-(

@ysc3839
Copy link

ysc3839 commented Oct 15, 2020

mshta.exe is just a stub that call RunHTMLApplication of mshtml.dll. It's useless if you only have source code of mshta.exe.

@ukandrewc
Copy link

Not if you have the source.

@champnic
Copy link
Member

I'm going to close this issue as it doesn't seem to be an ask on the WebView2 control, but rather a discussion of how to move forwards with HTA. Feel free to continue the discussion here though!

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

I would but it's expired ;-(

Here it is:
powerof.zip

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

mshta.exe is just a stub that call RunHTMLApplication of mshtml.dll. It's useless if you only have the source code of mshta.exe.

Can you please point is to some online resource talking about this? Unless you mean:

rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";alert('foo');

I think mshta.exe is more than that. It is com client that also encapsulates that functionality, and it is also a normal app to which *.hta files are associated and also is a win32 app which receives the HTA file name that is executed. It also has important security-related programming inside that solves few important issues.

Thus, if you do WIN+R and then paste e.g . C:\Users\ysc3839\Downloads\powerof.hta mshta.exe will take over and execute that hta ....

@ysc3839
Copy link

ysc3839 commented Oct 15, 2020

Can you please point is to some online resource talking about this?

No. I know it by disassemble mshta.exe.

@ukandrewc
Copy link

Can't look at powerof.zip every AV I have, says it contains a trojan.

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

Can't look at powerof.zip every AV I have, says it contains a trojan.

(laugh) it does not , win 10 always says that about ht... I can send you the whole file as a txt attached to an email or even better I can make a Gist?

@ukandrewc
Copy link

That's OK you've answered the basic question, that it's not VBS.

All you need to do is download the community edition of Visual Studio, then create a simple form with a basic WebView2.

With very little tweaking you will be able package your HTA code in your own app.

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 15, 2020

powerof.hta gist is here: https://gist.github.com/DBJDBJ/e459b21072948bcacbed5e966f4801bf

Hopefully, it is obvious it is not a "virus" :) Please use it. Just save it to your desktop as hta file, double click and enjoy.

I still do not follow this: "... create a simple form with a basic WebView2."? Are we talking C# here?

@champnic
Copy link
Member

Doesn't look like a virus to me 👍

You can use WebView2 with C#/.NET using WPF or Winforms, Win32/C++, or WinUI 3.0 (still in development). The "Getting Started" guides are a good place to start:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 16, 2020

Doesn't look like a virus to me 👍

It is a complete desktop app with a fully functional GUI. Minus any C#, C++, VB, WPF, Winforms, WinUI, no .NET whatsoever. And it is not a trick and it is not a hack.

It is 21 years mature, and in every copy of WIN10, just like mshtml.dll on which it is based. And it can be used today.

It just works™

@ukandrewc
Copy link

ukandrewc commented Oct 16, 2020

@DBJDBJ Loaded that into WebView2 and it all works, so you can quite easily build your own app for it.

As you're using JS, C# should be easy enough for you, but you can also use F# or VB.

Only down side at the moment, is that you'll need to package it, but that will change.

I'm sure once it's mature, Edge/WebView2 will be bundled with Windows, just as mshtml/IE is today.

@ukandrewc
Copy link

Doesn't look like a virus to me

Fair enough, probably rejected it because it was an HTA/HTA.exe, I didn't argue, just removed it.

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 16, 2020

@DBJDBJ Loaded that into WebView2 and it all works, so you can quite easily build your own app for it.

As you're using JS, C# should be easy enough for you, but you can also use F# or VB.

Only downside at the moment, is that you'll need to package it, but that will change.

I'm sure once it's mature, Edge/WebView2 will be bundled with Windows, just as mshtml/IE is today.

The KEY POINT™

HTA does not need .NET. It has nothing to do with .NET anything. It goes around 20 years of .NET and delivers. And oh, it goes around UWP too.

ps: @ukandrewc many thanks for your involvement, I am not arguing with you.

@ukandrewc
Copy link

Agreed, but it's old technology, and things have moved on. HTA has been superceded by cross platform PWA. I was just offering a solution to using your HTA in WebView2.

@DBJDBJ
Copy link
Author

DBJDBJ commented Oct 16, 2020

@ukandrewc again: I am not arguing with you but :) Some "Things" have moved on but into the wrong direction, like UWP. And one does not need any of .NET to create full-blown non-trivial Windows desktop app.

One does not need Edge related control curiously called "WebView2" to execute HTA. But. That certainly can be done. But the thing is not even released yet.

PWA has absolutely nothing to do with HTA. HTA when executed is "just" a Windows desktop app. It is not OS-agnostic and it is not device agnostic too. Neither it wants to be. HTA is not a web page running locally. It is html/js/css combo rendered every time locally when executed. There is no any kind of networking needed or involved for HTA. It is completely handled by mshtml.dll

"old technology"?: There is also such a thing called "mature technology". Like for example Win32 C/C++ App. Windows is also "old technology" but also "mature technology".

image

@ukandrewc
Copy link

ukandrewc commented Oct 16, 2020

Oh well, I'll leave it there then ;-)

@MicrosoftEdge MicrosoftEdge deleted a comment from niutech Aug 10, 2021
@DBJDBJ
Copy link
Author

DBJDBJ commented Aug 11, 2021

Was @niutech politically incorrect ;)

@champnic
Copy link
Member

lol linking to leaked Windows source code on a Microsoft forum. More "businessally incorrect"?

@gnh1201
Copy link

gnh1201 commented Feb 14, 2022

I am also interested in this issue.

I have focused on using HTA like Electron in recent years. It received a greater response than expected.

This is the result: https://github.com/gnh1201/welsonjs

I think the improvement of JScript has already been made by Chakracore. However, Chakracore does not include HTML rendering, so it is currently not available like Electron. (e.g. chakra-core/ChakraCore#6622)

I want to make an improved HTA based on MSHTML or EdgeHTML. The best way is for HTA to be released as an open-source.

@DBJDBJ
Copy link
Author

DBJDBJ commented Feb 14, 2022

I will not be gloating :)

https://www.thewindowsclub.com/msedgewebview2-exe-high-cpu-and-memory-usage

mshta.exe is very different solution. it also does not require electron.

mshta.exe is highly likely a really small code. why can't we just have it please as open source?

@terremoth
Copy link

terremoth commented Mar 30, 2022

I agree. I think we should talk seriously about making an open source version of MSHTA.exe and its implementation to run VBScript files. And further: implement the open source solution to Wine to execute hta files on Linux.

Also: I don't know if this is the right place to ask that. Making desktop applications with HTA+VBScript is far better and less bloated than Electron for example.

@niutech
Copy link

niutech commented Mar 30, 2022

There are already many lightweight cross-platform alternatives for Electron: WebView, WebWindow, Photino, Neutralino, DeskGap, Tauri, Ultralight, NodeGui, Sciter.JS, Graffiti, EdgeSharp. MSHTA is only for Windows.

@gnh1201
Copy link

gnh1201 commented Mar 31, 2022

All of the alternatives presented are not suitable for accessing the COM interface with Javascript in Windows.

Windows can perform a wide variety of native tasks through the COM interface. JScript (including Chakra) can finish this with at least three lines.

MSHTML and EdgeHTML (e.g. MSHTA) have access to COM interface and HTML rendering, so I can create lightweight Windows applications.

If I have to use a different base, I can't predict how much effort it will take and how big the program will be.

@niutech
Copy link

niutech commented Mar 31, 2022

As @ysc3839 said, all mshta.exe does is invoke RunHTMLApplication from mshtml.dll, so open sourcing it won't do much.
The original comment in mshtml/src/other/hta/main.cxx says:

// Simply a pass-through entry point. It forwards this call to MSHTML's
// exported RunHTMLApplication API.

@terremoth
Copy link

There are already many lightweight cross-platform alternatives for Electron: WebView, WebWidow, Photino, Neutralino, DeskGap, Tauri, Ultralight, NodeGui, Sciter.JS, Graffiti, EdgeSharp. MSHTA is only for Windows.

Far different things from MSHTA.
MSHTA runs VBScript and can call/send info to scripts out of the .hta file.
None of these solutions you cited do this.

@niutech
Copy link

niutech commented Apr 1, 2022

@terremoth Really? It's not VBScript, but Photino can invoke native .NET methods, see e.g. this sample.

@gnh1201
Copy link

gnh1201 commented Apr 1, 2022

@niutech Photino uses window.external for the interface. However, since this is a deprecated(not recommanded) feature, it doesn't seem to be an appropriate alternative. https://developer.mozilla.org/en-US/docs/Web/API/Window/external

@DBJDBJ
Copy link
Author

DBJDBJ commented Apr 1, 2022

There are already many lightweight cross-platform alternatives for Electron: WebView, WebWidow, Photino, Neutralino, DeskGap, Tauri, Ultralight, NodeGui, Sciter.JS, Graffiti, EdgeSharp. MSHTA is only for Windows.

Those are not MSHTA alternatives.

@DBJDBJ
Copy link
Author

DBJDBJ commented Apr 1, 2022

There are already many lightweight cross-platform alternatives for Electron: WebView, WebWidow, Photino, Neutralino, DeskGap, Tauri, Ultralight, NodeGui, Sciter.JS, Graffiti, EdgeSharp. MSHTA is only for Windows.

Far different things from MSHTA. MSHTA runs VBScript and can call/send info to scripts out of the .hta file. None of these solutions you cited do this.

@terremoth

We agree, but can you please stop mentioning VB Script? mshta.exe will work for you as it is. We just want it open sourced, that is all. Keep the message succint.

@terremoth
Copy link

@terremoth Really? It's not VBScript, but Photino can invoke native .NET methods, see e.g. this sample.

too bureaucratic.

@terremoth
Copy link

terremoth commented Apr 1, 2022

There are already many lightweight cross-platform alternatives for Electron: WebView, WebWidow, Photino, Neutralino, DeskGap, Tauri, Ultralight, NodeGui, Sciter.JS, Graffiti, EdgeSharp. MSHTA is only for Windows.

Far different things from MSHTA. MSHTA runs VBScript and can call/send info to scripts out of the .hta file. None of these solutions you cited do this.

@terremoth

We agree, but can you please stop mentioning VB Script? mshta.exe will work for you as it is. We just want it open sourced, that is all. Keep the message succint.

Irony? If not, what's the problem with mentioning VBS? VBS with COM interfacing is literally the greatest feature that can be used in HTA. HTA without VBS is just a simple HTML with extras window features.

Edit: I know all this thread/issue isn't about VBS itself, it is just the HTA greatest feature still working on Windows (and hope it continues), and I just mention there should be a place people could talk about this these days, and mainly: create an open source version of it.

@DBJDBJ
Copy link
Author

DBJDBJ commented Apr 5, 2022

@terremoth not irony ... keep your message clean and with no drama and no tangential opinions...

Open Source mshta.exe

Simple

@terremoth
Copy link

looooooooooooool

@gnh1201
Copy link

gnh1201 commented Apr 19, 2022

I found a repository that mentioned this issue. He seems to be using MSHTML and Chakracore to solve.

https://github.com/jscherer92/Quark

@gnh1201
Copy link

gnh1201 commented Apr 19, 2022

I think @jscherer92's comment exactly explains this issue.

Microsoft has decided to go with the Chromium engine for their browser and that would hopefully mean that they will expose it as an API for the COM system. If not, well, we are going to have the same bloated interfaces that you get with NWJS or Electron sadly.

@squadjot
Copy link

I'm totally with you DBJDBJ , would be very cool to have mshta render with WebView2

Actually neutralinojs is pretty cool and, thats the closest i've got to a replacement. But there's no new ActiveXObject() equivalent :/ - You could build your own API, and just execute scripts outside the app.

Allthough.... it is definitely possible to implement the javascript (jscript) COM interface in a modern WebView.. just like in a HTA. And i did it with Edge WebView2 in a c# .net app .. in the end i didn't complete the project, because i didn't like the fact that it was dependent on .NET.

There's some guys over at the autoit forums that got something going on.. could be promising.
https://www.autoitscript.com/forum/topic/204362-microsoft-edge-webview2-embed-web-code-in-your-native-application/

@squadjot
Copy link

squadjot commented Nov 28, 2024

One thing, why would you need mshta open source? The huge advantage of mshta.exe is that it's installed, and ready to run on literally every windows machine. An "open source" mshta would just be some 3rd part unsigned software.. and i bet the sourcecode is not really worth much. imo..

Anyways, the main thing that makes HTA so powerfull, is the ActiveXObject() method. This can , as mentioned, be implemented relative easy in webview2!.. it's just one function. In a C# .NET app, it's litterally one line of code :

public Object NewActiveXObject(String progId) { return (Activator.CreateInstance(Type.GetTypeFromProgID(progId))); }

If anything... it would make sense to just build a new and better version of "mshta", and maybe add some functionality, along the lines of what NeutralinoJS did.

@DBJDBJ
Copy link
Author

DBJDBJ commented Dec 3, 2024

Imagine:

npm mshta

Get it? 😀 Even if it is just for Win and just WebView2. If in npm as OSS, Microsoft or not , people can safely base projects on it.

Same as then, people will have full support, advice, debugging etc. VSCode extension , the lot.

@niutech
Copy link

niutech commented Dec 3, 2024

@DBJDBJ Why would anybody use Node Package Manager to install a Windows runtime independent of Node? If anything, WinGet or Chocolatey is the way. But I think we have much more modern cross-platform open-source web engines to build new apps, which I mentioned earlier. MSHTA should be open sourced but rather for archival purposes and legacy apps.

@DBJDBJ
Copy link
Author

DBJDBJ commented Dec 9, 2024

Nothing to do with node.

Once upon a time, vbs and js interpreters have been outside of IE browser.

Scripting on Win was wild. WSC , HTA components and the rest.

That was all tightly coupled to COM . ProgID's, "new:" moniker and the rest.

@gnh1201
Copy link

gnh1201 commented Dec 10, 2024

Take a look at the [issue I referenced](gnh1201/welsonjs#157). It contains all the known resources needed to create an open-source version of mshta. If someone truly needs it, they can use this as foundational material to build it.

@terremoth
Copy link

My interest back in the time was for a MSHTA implementation that could deal/read vbscript and activex objects in the page, interacting with COM, etc, so GUI apps could be made with html+css+js+vbs + a database. But I see Microsoft wants to bury definitely this kind of technology.

Today I kind of agree with that, since you can do progressive web apps (PWA) (and even suggest browsers to install the PWA as an offline Windows app) and use in-browser databases such as Dexie.js, pouchdb, localforage, idb and many others, and use a more updated JavaScript ecosystem

@squadjot
Copy link

squadjot commented Dec 10, 2024

@DBJDBJ

Scripting on Windows has remained largely consistent since the release of Windows Vista. Both JavaScript (JScript) and VBScript can still be used with the Windows Script Host (via wscript.exe or cscript.exe). ( Can be wrapped in WSF files, was it those you meant? ("WSC"?) )

Additionally, HTAs supports Javascript (JSCRIPT) and VB in IE Mode <9 (..i think..or it's <8)

Internet Explorer (standalone installation) and the COM version (InternetExplorer.Application / IWebBrowser2) , are two different things.
Even if Internet Explorer (standalone installation) were fully removed from a system, the COM version will still be available and functional. Some legacy scripting/functionality is still dependent on it. ( HTA's are in no way dependent of standalone installations of internet explorer)

My guess is that mshta does not contain any "magical" functionality, It primarily serves as GUI interfacing with the Windows API and COM, which handle most of the underlying operations.

@DBJDBJ
Copy link
Author

DBJDBJ commented Dec 11, 2024

That's what I said. I said it in less detail though 👌. WSC is/was Windows Scriping Component.

These years I am far from coding.

I just want quick js scripts with html gui. Built in Win. No PS and no .net. Just cmd.exe. No bat.

If thats still inside, fine.

I just don't want be thinking mshta.exe might dissapear one day. Because it stayed by accident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants