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

ActiveX component can't create object 'wscript.filesystemobject'

394 views
Skip to first unread message

Hermes

unread,
Apr 3, 2003, 11:45:42 AM4/3/03
to
Hi all. This is the error I get from vbscript in an hta. The line of code
I get it on is

Set objSh = CreateObject("wscript.Shell")

I have tried changing wscript to scripting with no luck. If I understand
correctly, wscript won't work in a script in html, but it should work within
an hta because the hta doesn't have such restrictive security. I have NT4
sp6a with IE 5.5 sp2 and wsh 5.6 on the workstation. The hta runs off of an
intranet webpage on a NT4 server, but I think all of the stuff it calls in
the script it uses from the workstation, not the server. I don't understand
why I'm getting this error, can anyone help? TIA


Hermes

unread,
Apr 3, 2003, 12:01:14 PM4/3/03
to

I noticed a couple more things about this problem. The MS script debugger
highlights and indicates the objSh line, but the error message seems to
refer to the objFS line after it. Also, I have another similar hta on the
server that also has the below lines of code in it and it runs fine, doesn't
get the same errors. I have compared the two hta's next to each other, line
by line and don't see any differences that would fix the problem. :(
Again, thanks for any help.

Set objSh = CreateObject("wscript.Shell")

Set objFS = CreateObject("wscript.FileSystemObject")


Hermes

unread,
Apr 3, 2003, 4:43:50 PM4/3/03
to
Greetings again. I found this post in Google and thought that one thing
said by Micheal Harris in it maybe my problem? And I quote:

"Just remember that wscript/cscript.exe is still NOT the host. So the
intrinsic WScript object isn't
available, but the entire DHTML DOM is (pretty fair trade if you ask me..."

Could this be the problem? If so, then why does one script work fine with
this and another doesn't? Thanks again.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=efX7S3eQ
BHA.1408%40tkmsftngp05&rnum=20&prev=/groups%3Fq%3D%252Bhta%2B%252Bhtml%2B%25
2Bsecurity%2B%252Bvbscript%26start%3D10%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%
3DUTF-8%26selm%3DefX7S3eQBHA.1408%2540tkmsftngp05%26rnum%3D20


Hermes <her...@messenger.com> wrote in message
news:efiCmKg#CHA....@TK2MSFTNGP12.phx.gbl...

Alex K. Angelopoulos (MVP)

unread,
Apr 3, 2003, 5:14:00 PM4/3/03
to
Hermes,

A couple of notes here.

(1) Your problem is the FSO line. That should be

"Scripting.FilesystemObject"

(2) You cannot use the WScript object from anything but WSH, but that has
nothing to do with either "Wscript.Shell" or "WScript.Network", which are merely
COM objects with WScript in their ID. The WScript object is the intrinsic one
used as a prefix for certain intrinsic WSH methods. The following are things
you can't do in an HTA:

WScript.CreateObject("My.Object")
WScript.Sleep 10
WScript.Echo "Hello, World!"

All of your stuff is OK; just fix the reference to "Scripting.FileSystemObject".

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
----------
Microsoft's new UNIFIED Terminal Services Newsgroup:
news:microsoft.public.windows.terminal_services

Hermes

unread,
Apr 4, 2003, 9:33:43 AM4/4/03
to
I get a error on the same line if I make that change in this script. The
error: "Object required: Wscript". This is the error I get if I change the
line(s) in error from

Set objSh = CreateObject("wscript.Shell")
Set objFS = CreateObject("wscript.FileSystemObject")

To

Set objSh = Wscript.CreateObject("scripting.Shell")
Set objFS = CreateObject("scripting.FileSystemObject")


It was one of the first things I tried. Does anyone know why? Thanks for
the reply.

Alex K. Angelopoulos (MVP) <a...@mvps.org> wrote in message
news:e6Y8S5i#CHA....@TK2MSFTNGP12.phx.gbl...

Torgeir Bakken (MVP)

unread,
Apr 4, 2003, 9:52:32 AM4/4/03
to
Hermes wrote:

> I get a error on the same line if I make that change in this script. The
> error: "Object required: Wscript". This is the error I get if I change the
> line(s) in error from
>
> Set objSh = CreateObject("wscript.Shell")
> Set objFS = CreateObject("wscript.FileSystemObject")
>
> To
>
> Set objSh = Wscript.CreateObject("scripting.Shell")
> Set objFS = CreateObject("scripting.FileSystemObject")
>
> It was one of the first things I tried. Does anyone know why?

Hi

You can't use 'Wscript.CreateObject(...' from a HTA script,
you need to use 'CreateObject(...'

and there is no object called "scripting.Shell" either, you will need to use
"Wscript.Shell".


This should work from your HTA script:

Set objSh = CreateObject("Wscript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")


--
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/scriptcenter


Hermes

unread,
Apr 4, 2003, 11:45:29 AM4/4/03
to
Wow, I guess I was alittle confused. Thank you so much for helping me
understand and fix the problem Torgeir! Where is a good reference for using
a vbscript in an hta? I have checked Microsoft site and google, but haven't
found anything. If I was able to find it in the first place I think I would
not have had this problem to begin with. I would like to learn things like
what specifically can and can't be done in an hta with a vbscript, how
things need to be coded in order to work, etc. Or mabey if that info isn't
readily available online, is there a good book about it I should get?
Thanks.

Torgeir Bakken (MVP) <Torgeir.B...@hydro.com> wrote in message
news:3E8D9C30...@hydro.com...

0 new messages