Re: Deleting files with ASP

From: Jon (js_at_roksteady.net)
Date: 03/08/04


Date: Mon, 8 Mar 2004 14:09:06 -0000

I think ideally you should change permissions to give iusr full control over
the folder. If that's not possible then changing from
>> If objfs.FileExists(serverfilename) Then
>> debugwrite "deleting " & serverfilename
>> objfs.deletefile(serverfilename)
>> end if
>> Set objFile = objFS.CreateTextFile(serverfilename)
to just
Set objFile = objFS.CreateTextFile(serverfilename)

should work - remember we don't need to delete the file first as it will be
over-written by createtextfile. Deleting a file obviously requires more
permissions than writing to a file

Jon

JA wrote:
> I sent your posts to the programmer, he said:
>
> I have tried the second parameter a few days ago and it made no
> difference. I got the same permission denied problem
>
>
> Thanks again, Jill
>
>
>
> "JA" <jarmour@kc.rr.com> wrote in message
> news:hCQ2c.3510$4B1.2158@twister.rdc-kc.rr.com...
>> Thanks, both of you, for your replies.
>>
>> Here is a smaller version of his logic that he made to show what is
>> happening. I don't know much about this, but it looks to me like
>> this script is trying to delete the file and then rewrite it. He
>> (the programmer) has said that he has tried both overwriting and
>> deleting. I can run this once, and the file will be created. If I
>> run it again, I get this error:
>>
>> __________________________________
>>
>> Microsoft VBScript runtime error '800a0046'
>>
>> Permission denied
>>
>> /folder/testfiles.asp, line 10
>>
>> ___________________________________
>>
>> Only if I delete the file manually, I can run it again. Here is the
>> script:
>>
>> ____________________________________
>>
>> <%Response.buffer=TRUE%>
>> <!-- #include file="st$db.asp"-->
>> <!-- #include file="fileio.asp"-->
>> <%
>> serverfilename="folder/filetest.txt"
>> Set objFS = CreateObject("Scripting.FileSystemObject")
>> serverfilename = Server.Mappath(serverfilename)
>> If objfs.FileExists(serverfilename) Then
>> debugwrite "deleting " & serverfilename
>> objfs.deletefile(serverfilename)
>> end if
>> Set objFile = objFS.CreateTextFile(serverfilename)
>> debugwrite "Creating " & serverfilename
>> objfile.WriteLine "This is a test line"
>> objfile.close
>> set objfs=nothing
>>
>> %>
>>
>> ___________________________________
>>
>> I'm going to send him what both of you wrote. If you see something
>> else wrong in the script, please let me know.
>>
>> Thank you!!
>>
>> Jill
>>
>>
>> "Jon" <js@roksteady.net> wrote in message
>> news:uhJ%23%23dKBEHA.1796@TK2MSFTNGP12.phx.gbl...
>>>> This depends somewhat on how you're creating the file.
>>>> For example, if you're using the
>>>> Scipting.FileSystemObject's CreateTextFile method, you
>>>> have to specify a second parameter such as
>>>>
>>>> fso.CreateTextFile("myfile.txt", true)
>>>>
>>>> if you want to overwrite any existing file. The default
>>>> for this method, is false, meaning that the
>>>> FileSystemObject won't overwrite existing files.
>>>
>>> Wrong way around - the default is to over-write unless you specify
>>> false. For example
>>> set f=oFso.createtextfile("c:\text.txt")
>>> the same as
>>> set f=oFso.createtextfile("c:\text.txt",true)
>>> would over-write text.txt if it existed. But
>>> set f=oFso.createtextfile("c:\text.txt",false)
>>> would give a "file exists" error if the file already exists.
>>>
>>> We would need to see the code (and the exact error message) to be
>>> able to help further.
>>>
>>> Jon
>>> Microsoft MVP - FP
>>>
>>> Jim Buyens wrote:
>>>>> -----Original Message-----
>>>>> Hi,
>>>>
>>>> Howdy.
>>>>
>>>>> I am using FP 2000 on IIS4/NT. I have an asp script that
>>>>> creates some files from a database. It writes from a
>>>>> private subfolder ( _folder) to a subfolder of the
>>>>> private subfolder ( _folder/folder).
>>>>>
>>>>> It will work once, but once the files are in there, I
>>>>> can't run the script again and overwrite them. I get
>>>>> a "permission denied" error. If I go in and manually
>>>>> delete the files, it will work again.
>>>>>
>>>>> Neither the programmer or my ISP can figure out what is
>>>>> wrong. The only other thing I can think of is a
>>>>> FrontPage quirk.
>>>>>
>>>>> Does anyone have any ideas on this?
>>>>> Thanks, Jill
>>>>
>>>> This depends somewhat on how you're creating the file.
>>>> For example, if you're using the
>>>> Scipting.FileSystemObject's CreateTextFile method, you
>>>> have to specify a second parameter such as
>>>>
>>>> fso.CreateTextFile("myfile.txt", true)
>>>>
>>>> if you want to overwrite any existing file. The default
>>>> for this method, is false, meaning that the
>>>> FileSystemObject won't overwrite existing files.
>>>>
>>>> For more information on Scripting.FileSystemObject
>>>> methods, browse:
>>>>
>>>> http://msdn.microsoft.com/library/en-us/script56/html/
>>>> fsooriScriptingRun-TimeReference.asp
>>>>
>>>> If this doesn't point to a solution, please post again to
>>>> this thread and include the exact block of code that's
>>>> failing.
>>>>
>>>> Jim Buyens
>>>> Microsoft FrontPage MVP
>>>> http://www.interlacken.com
>>>> Author of:
>>>> *----------------------------------------------------
>>>>> \---------------------------------------------------
>>>>>> Microsoft Office FrontPage 2003 Inside Out
>>>>>> ---------------------------------------------------
>>>>>> Web Database Development Step by Step .NET Edition
>>>>>> Microsoft FrontPage Version 2002 Inside Out
>>>>>> Faster Smarter Beginning Programming
>>>>>> (All from Microsoft Press)
>>>>> /---------------------------------------------------
>>>> *----------------------------------------------------



Relevant Pages

  • Re: cant get access to disk share when connecting from a remote s
    ... The systems are DUTs. ... for each of the drives within the system. ... Everything in the scripts work except the file permissions below the shares ... the shares on the DUTs manually, after they run my rename script, but I would ...
    (microsoft.public.windows.server.scripting)
  • Re: VBA Script to Read WMP 11 Database
    ... The script failed on the desktop when I downloaded WMP11, ... Just reviewing the bidding -- WMP 11 responds properly to commands in a VBS ... That's why the computer wouldn't let me manually change the permissions. ... Digital Media MVP: 2004-2007 ...
    (microsoft.public.windowsmedia)
  • Re: VBA Script to Read WMP 11 Database
    ... The script failed on the desktop when I downloaded WMP11, ... Just reviewing the bidding -- WMP 11 responds properly to commands in a VBS ... That's why the computer wouldn't let me manually change the permissions. ... The CREATOR OWNER is likely on windows to be one of the admin accounts ...
    (microsoft.public.windowsmedia)
  • Re: how to restrict users to search in their own Organizational Unit
    ... will be given the necessary permissions. ... Who would you DENY? ... decided a script can make it possible to accomplish, ... If I need to create a security group per OU and then add all users ...
    (microsoft.public.windows.server.active_directory)
  • Re: Script to Copy Files from a Share to a Client Not Working
    ... regardless of the value of overwrite. ... I have the permissions applied now, ... The script is in place and is executing as ... > The copy is instructing the file located on a SERVER to ...
    (microsoft.public.windows.server.active_directory)