4

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?

2
  • Which WScript members do you need to use? Perhaps there are alternatives Commented Feb 11, 2013 at 21:06
  • I am using WScript.Echo and FileSystemObject objects Commented Feb 12, 2013 at 5:58

2 Answers 2

5

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>
Sign up to request clarification or add additional context in comments.

Comments

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

9 Comments

I am actually calling vbs file from bat file. Then from vbs I am calling HTA form to get user input and with inputs performing actions based on inputs.
Something like this? If so, you need to HTABox.document.write the JScript I suppose.
Now I have got an idea to call HTA file from bat file. But is it possible to fetch data from hta to batch file?
I'd be glad if you could tell me, how to interact between windows. I've used temporary files, which is working fine, except you can't pass real objects...
I will pass arguments to hta file like this: @call scripts\UserForm.hta "src" "dest" "op" Later in hta, i will store values in these arguments so that i can use them in bat file. I dont know if this makes sense or not
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.