Solved

Permission Denied.

Posted on 2002-06-25
11
694 Views
Last Modified: 2007-12-19
Thank You in advance
I have a page that works just fine for me. Nobody else can get to it. They get Permission Denied. I have the exact same right on the folder the file is being written to. The line that it is crashing on is:

set file = fso.CreateTextFile(thePath, true)

Does CreateTextFile use some dll or something to that effect. My nt account is set up the exact same and I have the same rights(change) on the folder where I am trying to create the text file.
Thank You,
Kent
0
Comment
Question by:kmurphy7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 7108720
Make sure the IUSER_ has Write permission on the folder the text file is writing to.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 7108724
If
>>I have the exact same right on the folder the file is being written to

then my first guess would be thePath var with CreateTextFile.
Check the value of thePath, whetehr they have permission on to that folder.
thepath is in correct format etc.
Do a Response.write thePath and see the value
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7108728
And of course, from MSDN;

Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
   MyFile.WriteLine("This is a test.")
   MyFile.Close
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kmurphy7
ID: 7108857
Sorry, I forgot to note that Basic is turned on and Anonymous is turned off. Here is the full code.


Dim IniFileDictionary
set IniFileDictionary = CreateObject("Scripting.Dictionary")

Sub IniFileLoad(ByVal FilSpc)
  Dim PhyPth
  Dim FilSys
  Dim IniFil
  Dim StrBuf
  Dim HdrBuf
  Dim StrPtr
  Dim AltBuf
  IniFileDictionary.RemoveAll
  FilSpc = lcase(FilSpc)
  if left(FilSpc, 1) = "p" then
    'Physical path
    PhyPth = mid(FilSpc, instr(FilSpc, "=") + 1)
  else
    'Virtual path
    PhyPth = Server.MapPath(mid(FilSpc, instr(FilSpc, "=") + 1))
  end if

  set FilSys = CreateObject("Scripting.FileSystemObject")
  set IniFil = FilSys.OpenTextFile(PhyPth, 1)
  do while not IniFil.AtEndOfStream
    StrBuf = IniFil.ReadLine
    if StrBuf <> "" then
      'There is data on this line
      if left(StrBuf, 1) <> ";" then
        'It's not a comment
        if left(StrBuf, 1) = "[" then
          'It's a section header
          HdrBuf = mid(StrBuf, 2, len(StrBuf) - 2)
        else
          'It's a value
          StrPtr = instr(StrBuf, "=")
          AltBuf = lcase(HdrBuf & "|" & left(StrBuf, StrPtr - 1))
          do while IniFileDictionary.Exists(AltBuf)
            AltBuf = AltBuf & "_"
          loop
          IniFileDictionary.Add AltBuf, mid(StrBuf, StrPtr + 1)
        end if
      end if
    end if
  loop
  IniFil.Close
  set IniFil = nothing
  set FilSys = nothing
End Sub

Function IniFileValue(ByVal ValSpc)
  dim ifarray
  Dim StrPtr
  Dim StrBuf
  StrPtr = instr(ValSpc, "|")
  ValSpc = lcase(ValSpc)
  if StrPtr = 0 then
    'They want the whole section
    StrBuf = ""
    StrPtr = len(ValSpc) + 1
    ValSpc = ValSpc + "|"
    ifarray = IniFileDictionary.Keys
    for i = 0 to IniFileDictionary.Count - 1
      if left(ifarray(i), StrPtr) = ValSpc then
        'This is from the section
        if StrBuf <> "" then
          StrBuf = StrBuf & "~"
        end if
        StrBuf = StrBuf & ifarray(i) & "=" & IniFileDictionary(ifarray(i))
      end if
    next
  else
    'They want a specific value
    StrBuf = IniFileDictionary(ValSpc)
  end if
  IniFileValue = StrBuf
End Function



call IniFileLoad("virtual=Common/expenseReport.ini")
thePath = IniFileValue("SaveErs|Path") & "include.txt"

set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.CreateTextFile(thePath, true)
file.WriteLine("Created on " & now)
file.Close


Thanks Again,
Kent
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 7108861
What does thePath returns ? Did you check that ?
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 300 total points
ID: 7108886
In VBScript, when you CreateObject, you must call out the Server property on the object;

set IniFileDictionary = Server.CreateObject("Scripting.Dictionary")

set FilSys = Server.CreateObject("Scripting.FileSystemObject")

Thats first.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7108891
Second of all, with Basic authentication, the logged in user must have Read/Write on the directory that the FSO is attempting to write to.
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 7109896
permissions indeed..
0
 
LVL 1

Expert Comment

by:lmred
ID: 7191296
I had the same problem today. I resolved it by making sure the path was not a network path. Example instead of "\\server\foldername\file", I put "d:\foldername\file".


lmred
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7191697
As I said...

Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
0
 
LVL 4

Expert Comment

by:Wakie
ID: 9355509
It appears this question has been abandoned.

I will leave a recommendation in the Cleanup topic area that this question will be:

- Points to mgfranz -

Please leave any comments here within the next seven days.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Wakie,
EE Cleanup Volunteer.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
File download script VBSCRIPT fail on download PPT files 2 69
Date on a table 16 34
Validating Date 4 28
Update the value of table B with value of table A tables inner join 6 77
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question