2

I have the following code:

<%
dim deviceid
dim fso
dim outFile

deviceid=Request.QueryString("deviceid")

If deviceid<>"" Then
    Response.Write("Hello " & deviceid & "!<br>")

    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set outFile = fso.CreateTextFile("C:\Users\Victor\Desktop\respTank.txt")
    outFile.WriteLine("Hello World!")
    outFile.close

    set outFile = nothing
    set fso = nothing

End If
%>

I get the following error:

Microsoft VBScript runtime error '800a0046'
Permission denied

I gave all permissions to IIS_IUSRS but it didn't help. Can anyone help me here?

user692942
  • 16,398
  • 7
  • 76
  • 175
vicesbur
  • 335
  • 2
  • 5
  • 13
  • Is the web application running as the Application Pool Identity? If not adding `IIS_IUSRS` will not help. – user692942 Aug 07 '14 at 11:25
  • the DefaultAppPool has the Application Pool Identity selected – vicesbur Aug 07 '14 at 11:35
  • Is the `DefaultAppPool` the Application Pool the web application is using? – user692942 Aug 07 '14 at 11:41
  • Default Web Site has `DefaultAppPool` as Application Pool and `\inetpub\wwwroot` as Physical Path, where my asp file is located – vicesbur Aug 07 '14 at 11:52
  • Bit strange why you are trying to create a local file inside a User Profile directory, you might find there are extra security such as UAC (User Account Control) that is blocking the creation, other then that I can't help you sorry. – user692942 Aug 07 '14 at 11:54
  • Also check you are setting the minimum permissions at the highest level (`list folder` in `C:\Users`) then inheriting down to `Desktop` and setting at least `modify` at this level. – user692942 Aug 07 '14 at 11:57
  • where should create the file then? I tried also in the wwwroot directory but I get the same problem. If I use the method `Getfile` instead of the method `CreateTextFile` I get the message that the file doesn't exist. – vicesbur Aug 07 '14 at 12:39
  • 2
    Sounds to me like the web application is using a different user context check the Authentication section in IIS. Regardless of the Application Pool you can still set your own `Anonymous Account` on the web application. – user692942 Aug 07 '14 at 12:44
  • 1
    Thank you very much Lankymart! Indeed I had to change the user context of the web application to a user with enough rights. Thanks again for your help. – vicesbur Aug 07 '14 at 13:07
  • No problem glad to help, will leave a answer so you can accept it and this question isn't left unanswered. [What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers). – user692942 Aug 07 '14 at 13:31

2 Answers2

2

It sounds like the ApplicationPoolIdentity is not the user context being used by the Web Application.

Depending on the IIS Version, you want to check (using the Manager)

IIS 4-6

Web Site / Application Properties -> Document Security

IIS 7+

Web Site / Application -> Authentication

and check the Anonymous Account which can be set differently to the ApplicationPoolIdentity.

Based on this value apply the permissions (at least Modify) to the folder C:\Users\Victor\Desktop\ and you are good to go.

user692942
  • 16,398
  • 7
  • 76
  • 175
-2

I just had the same thing happening on a delete file, have you tried removing the parenthesis?

Set outFile = fso.CreateTextFile("C:\Users\Victor\Desktop\respTank.txt")

to

Set outFile = fso.CreateTextFile "C:\Users\Victor\Desktop\respTank.txt"
Community
  • 1
  • 1
kenneth
  • 43
  • 8