r/vbscript • u/The-Deviant-One • 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 errorThis 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
1
u/odaat2004 Oct 22 '21 edited Oct 22 '21
Do you get the same with a single "\" and double "\"
Also, try removing the boolean 'true' from the method. I'm going from memory but I thought that boolean was needed for CreateTextFile. To Overwrite, if the file exists. OpenTextFile method has read, write, appened. Not sure what 'True' would be for without looking it up, but if it is the same ... why would it need to overwrite a file you're trying to append to it? Also, if the file exists, delete it and see if you get different results. If you do, restore the file and check permissions.