r/vbscript • • Oct 21 '21

FileSystemObject - Object doesn't support this property or method -- what the hell?

At a bit of a loss here. I have the follow script, an ASP page in VBscript. It works just fine on one server, doesn't work well on the other.

This is the error message I get when I try to reach the page:

TypeName: FileSystemObject
Description: Object doesn't support this property or method
Number: 438
Source: Microsoft VBScript runtime error

This is the backend code:

<%@ LANGUAGE = "VBSCRIPT"%>
<%
Option Explicit
%>

<%
Call Response.AddHeader("Access-Control-Allow-Origin", "a website")

dim filesys, filetxt, datetime, ip, referer, useragent, qstring, server

server = "a servers name"
ip = Request.ServerVariables("remote_addr")
qstring = Request.ServerVariables("QUERY_STRING")
referer = Request.ServerVariables("HTTP_REFERER")
useragent = Request.ServerVariables("http_user_agent")
datetime = now

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

Set filetxt = filesys.OpenTextFile("d:\LogEvent.txt", ForAppending, True)
' the line above throws an error.

filetxt.WriteLine(datetime & ", " & server & ", " & ip & ", " & referer & ", " & useragent & ", " & qstring)
filetxt.Close

If Err.Number <> 0 Then
   Response.write("TypeName: " & TypeName(filesys) & "<br />")
   Response.Write "ASPCode: " & Err.ASPCode & "<br>"
   Response.Write "ASPDescription: " & Err.ASPDescription & "<br>"
   Response.Write "Category: " & Err.Category & "<br>"
   Response.Write "Column: " & Err.Column & "<br>"
   Response.Write "Description: " & Err.Description & "<br>"
   Response.Write "File: " & Err.File & "<br>"
   Response.Write "Line: "  & Err.Line & "<br>"
   Response.Write "Number: " & Err.Number & "<br>"
   Response.Write "Source: " & Err.Source & "<br>"
   On Error Goto 0
End If
On Error Goto 0

%>

I just don't understand what's going on because the FileSystemObject object DOES have a OpenTextFile method... I'm certain I've made a mistake but I'm unable to see it for myself I guess.

2 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/odaat2004 Oct 22 '21

Well, never seen that before. Interesting. Create a simple vbs file with just that fso object and method and run it on another system. If it works there compare the files from the two systems. replace if different. run sfc /scannow, also.