Using HTA in vbscript

拟墨画扇 提交于 2019-12-11 01:24:29

问题


While using HTA userform for VBscript, I found that HTA doesn't support WScript and its objects/methods.

Is there any alternate way of creating userform or is thery any way to make HTA support WScript?


回答1:


An alternative to WScript.Echo would be to simply add content to the DOM:

<script language="vbscript">
    dim div: set div = document.getElementById("output")
    div.innerText = "output"
</script>

<div id="output"/>

or if you want a dialogbox instead, you can use MsgBox()

<script language="vbscript">
    MsgBox "output"
</script>

You can use Scripting.FileSystemObject without WScript

<script language="vbscript">
    dim fso: set fso = CreateObject("Scripting.FileSystemObject")
    dim path: path = fso.GetAbsolutePathName(".")
    '... etc
</script>



回答2:


Put your Wscript code to a .wsf-file and call the script like this:

shell=new ActiveXObject('WScript.Shell');
shell.Exec('WScript //Job:job_id PATH_TO_YOUR_WSF_FILE');

Via .wsf you can use also methods like WScript.Sleep(), WScript.SendKeys() etc. which are not available in HTA.

More info at MSDN: Windows Script Host



来源:https://stackoverflow.com/questions/14813507/using-hta-in-vbscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!