Skip to content
Advertisement

Javascript – getting path of file dropped into HTA

I am building a little HTA for personal use, and would like to be able to drag and drop a file to the interface. Once the file is dropped, I would either automatically run it (assuming it fits some parameters I set, like file extension), or at least fill in the input box on the HTA interface.

I’ve searched extensively, but can’t find a solution. Thoughts?

Advertisement

Answer

An HTA obviously cannot be target of a shell drop operation – at least on my system, dropping something on an HTA is impossible.

This would imply you cannot directly do what you intend.

A .vbs can however be a drop target. Full paths of the dropped files are available via the WScript.Arguments.Unnamed collection.

HTA has access to it’s command line arguments via the commandLine Property. This would mean you could build a small helper VBScript that translates the dropped files into a command line and calls the HTA for you.

Note that you cannot drop endless amounts of files on a .vbs, and command lines are not unlimited either. There will be a length limit in the area of a few kB (I have not tried to find where exactly the limit is, just be prepared to face a limit.)

10 People found this is helpful
Advertisement