Solved

Error trying to use Server.CreateObject("Scripting.FileSystemObject") to browse local system

Posted on 2006-10-30
14
843 Views
Last Modified: 2008-01-09
I have a windows XP SP 2 system and I am trying to use the following code to browse documents in a specified folder on my system.

I get this error message


Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string


The code is

<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 ID="Table3" width=100%>
<TR BGCOLOR="#000000">
      <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Form</B></FONT></TD>
      <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Filename:</B></FONT></TD>
      <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Size:</B></FONT></TD>
      <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>File type:</B></FONT></TD>
      <TD class=inputbox><FONT COLOR="#FFFFFF"><B>Date created:</B></FONT></TD>
<%
' Create an instance of the FileSystemObject
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
' Create Folder Object
Set MyFolder=MyFileObject.GetFolder(Server.MapPath("../forms"))
'Loop trough the files in the folder
FOR EACH thing in MyFolder.Files
%>
<TR BGCOLOR="#F7F7E7">
      <TD  class=inputbox><img src="../forms/<%=thing.Name%>" width=50></TD>
      <TD  class=inputbox><A HREF="../forms/<%=thing.Name%>"><%=thing.Name%></A></TD>
      <TD ALIGN=RIGHT><%=thing.Size%>bytes</TD>
      <TD  class=inputbox><%=thing.Type%></TD>
      <TD><%=thing.DateCreated%></TD>
<%
NEXT
%>
</TABLE>

Very Important to get the asnwer ASAP

Thanks in advance.
0
Comment
Question by:souldj
14 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17837719
What line is throwing the error?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17837736
For troubleshooting, let's try this:

<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 ID="Table3" width=100%>
<TR BGCOLOR="#000000">
     <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Form</B></FONT></TD>
     <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Filename:</B></FONT></TD>
     <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>Size:</B></FONT></TD>
     <TD  class=inputbox><FONT COLOR="#FFFFFF"><B>File type:</B></FONT></TD>
     <TD class=inputbox><FONT COLOR="#FFFFFF"><B>Date created:</B></FONT></TD>
<%
' Create an instance of the FileSystemObject
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
If IsObject(MyFileObject) Then
      response.write "MyFileObjectCreated"
Else
      response.write "Could not create object"
End If
response.end
' Create Folder Object
Set MyFolder=MyFileObject.GetFolder(Server.MapPath("../forms"))
'Loop trough the files in the folder
FOR EACH thing in MyFolder.Files
%>
<TR BGCOLOR="#F7F7E7">
     <TD  class=inputbox><img src="../forms/<%=thing.Name%>" width=50></TD>
     <TD  class=inputbox><A HREF="../forms/<%=thing.Name%>"><%=thing.Name%></A></TD>
     <TD ALIGN=RIGHT><%=thing.Size%>bytes</TD>
     <TD  class=inputbox><%=thing.Type%></TD>
     <TD><%=thing.DateCreated%></TD>
<%
NEXT
%>
0
 
LVL 1

Author Comment

by:souldj
ID: 17837819
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")

This is the line giving the error.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17837892
Take a look at the last post in this thread:

http://www.thescripts.com/forum/thread460883.html

FtB
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 17837893
Hi,

Invalid class string means the DLL that your trying to reference is not registered on the machine. You will need to download the scripting dll from Microsoft. It is called scrrun.dll. It may be on your installation media.

Regards,

Lee
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17837955
Lee--

Sometimes that is the case, but other times it appears that inadequate permission settings results in the same error message.

FtB
0
 
LVL 1

Author Comment

by:souldj
ID: 17839857
Based on the URL provided by fritz_the_blank, I got


1) Logged onto the machine as an administrator, without the network being
connected.

2) Start > Run > regedit

3) HKEY_LOCAL_Machine > SOFTWARE > Classes > Scripting.FileSystemObject

4) Right Click and select Permissions.
If yours is like mine, there will be only one or two there.
Add the permissions for all the normal users - System, IUSR_..., Guests,
Administrator

5) HKEY_LOCAL_Machine > SOFTWARE > Classes > CLSID
Search for this {0D43FE01-F093-11CF-8940-00A0C9054228}
Add the same permissions that you added to #4

6) Save the registry

7) Reboot, cross your fingers and anything else that will cross (it worked
for me anyway)

8) Test your FSO program again, mine worked, I hope yours does as well.




I searched for the registry itme  HKEY_LOCAL_Machine > SOFTWARE > Classes > Scripting.FileSystemObject but when I got it , it had no values and allowed me to add no values to it.

What next? Is it time to ReInstall?
0
 
LVL 12

Expert Comment

by:sandip132
ID: 17839924
you need to adjust the permissions on the SCRRUN.DLL.
Here's how you do it:
Navigate to your WINNT\SYSTEM32 directory and find the SCRRUN.DLL. Right-click the file and select properties. Then click the security tab and ensure that the IUSR_<machinename> and IWAM_<machinename> accounts have "read" and "read & execute" permissions. That's it.
0
 
LVL 1

Author Comment

by:souldj
ID: 17840535
My machine name is Blueice and so I have added the users IUSR_blueice and IWAM_blueice to the permissions on the file SCRRUN.DLL and still getting the same error message
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17843244
Things are looking grim.

What if you create a .vbs file and run it on the machine when you are logged in as an administrator? If that works, then you know that the .dll is present, registered, and functioning. Moreover, that will point to a permissions error. If, on the other hand, that does not work, then that permissions are not the issue.

FtB

0
 
LVL 1

Author Comment

by:souldj
ID: 17843669
Can you give me a simple vbs file to run on my system? or recommend the code for one as I have never written one before
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 17843788
Paste the following into a text file and save it with a .vbs extention and then double click the file to execute it:

' Create an instance of the FileSystemObject
Set MyFileObject=CreateObject("Scripting.FileSystemObject")
' Create Folder Object
Set MyFolder=MyFileObject.GetFolder("C:\YourDirectoryGoesHere")
'Loop trough the files in the folder
FOR EACH thing in MyFolder.Files
      msgBox thing.Name
NEXT
0
 
LVL 1

Author Comment

by:souldj
ID: 17843822
Error was encountered.

Line 4 Char 1
Active X component can't create object "Scripting.FileSystemObject
Code: 800A01AD
Microsoft VDScript runtine Error


What now?
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 17843930
It seems that there may be something wrong with the .dll as Lee suggested. This might help:


http://support.microsoft.com/default.aspx/kb/194801
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question