Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using WScript in HTA applications

2,488 views
Skip to first unread message

Bob

unread,
Jun 9, 2004, 7:36:37 PM6/9/04
to
The code below causes an "Object required: 'WScript'" error when I run it.
I read somewhere that WScript is not available unless the script is run
using WScript.exe or CScript.exe. However, I have seen several sample
applications that use it in an HTA. What is the real scoop on this? Can I
do this? I have W2k SP4, IE 6 and WSH 5.6.

<html>
<HTA:APPLICATION ID="moveOrders">
<head>
<script language="vbscript">
Sub transfer_click()
set wsh = WScript.CreateObject("WScript.Shell")
End Sub
</script>
</head>

<body>
<form>
<input type="button" value="Transfer" onclick="transfer_click">
</form>
</body>
</html>


Torgeir Bakken (MVP)

unread,
Jun 9, 2004, 7:54:30 PM6/9/04
to
Bob wrote:

> The code below causes an "Object required: 'WScript'" error when I run it.
> I read somewhere that WScript is not available unless the script is run
> using WScript.exe or CScript.exe. However, I have seen several sample
> applications that use it in an HTA. What is the real scoop on this? Can I
> do this? I have W2k SP4, IE 6 and WSH 5.6.
>
> <html>
> <HTA:APPLICATION ID="moveOrders">
> <head>
> <script language="vbscript">
> Sub transfer_click()
> set wsh = WScript.CreateObject("WScript.Shell")
> End Sub

> (snip)
Hi

In this case, the solution is simple:

instead of


set wsh = WScript.CreateObject("WScript.Shell")

use
set wsh = CreateObject("WScript.Shell")


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx

Bob

unread,
Jun 10, 2004, 1:59:19 PM6/10/04
to
That was easy... Thanks

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:exQtl0nT...@tk2msftngp13.phx.gbl...

0 new messages