Search code examples
vbscriptasp-classicfilesystemobject

classic asp create text file on webserver: error 800a0034 Bad_file_name_or_number


I have a classic asp page in VBS and I am trying to create a file on the web server with the following code.

Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fso.CreateTextFile("\\localhost\inetpub\wwwroot\cs\batch\123456dirs.bat", true)

This returns the following error:

|666|800a0034|Bad_file_name_or_number

Line 666 is the CreateTextFile line.

According to the Microsoft docs, this means that I'm trying to create a file with an invalid filename. Then it explains the rules for filenames and mine appears to be perfectly valid.

Any suggestions or ideas on how I can further troubleshoot this?


Solution

  • first thing to check to make sure your users have access to the folder. Assuming you're not using windows authentication, make sure IUSR account has write access to the folder.

    second, unless inetpub is set up as a share to folder, you're syntax won't work. if the root of your website is located in the CS folder, you can do something like:

    Set file1 = fso.CreateTextFile(Server.MapPath( "/cs/batch/123456dirs.bat" ), true)