Link to home
Start Free TrialLog in
Avatar of Destiny Amana
Destiny AmanaFlag for Nigeria

asked on

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

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.
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

What line is throwing the error?

FtB
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
%>
Avatar of Destiny Amana

ASKER

Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")

This is the line giving the error.
Take a look at the last post in this thread:

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

FtB
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
Lee--

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

FtB
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?
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.
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
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

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
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
Error was encountered.

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


What now?
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial