Permission denied on K*ll

Token Jester

New member
Local time
Today, 00:15
Joined
Apr 6, 2007
Messages
4
Hello, I am attempting to k*ll a file after I have moved it from one folder into a subdirectory of that folder.
Code:
    Dim FileSystem, folder, objFile
    Set FileSystem = CreateObject("Scripting.FileSystemObject")
    Set folder = FileSystem.GetFolder("D:\Work\TopLevelFolder")
    Set filecollection = folder.Files
    For Each file In filecollection
        Set ObjTStream = FileSystem.OpenTextFile("D:\Work\TopLevelFolder\" & file.Name, 1)
        Do While Not ObjTStream.AtEndOfStream
            strLine = ObjTStream.ReadLine
            '''''Go through a bunch of steps to parse lines and insert into table
        Loop
        FileSystem.MoveFile "D:\Work\TopLevelFolder\" & file.Name, "D:\Work\TopLevelFolder\Done\" & file.Name
        K*ill ("D:\Work\TopLevelFolder\" & file.Name)
    Next
Everything runs great with the exception of the K*ll command. I have tried FileSystem.MoveFile with the same error message.

Any ideas?

Thanks in advance - TJ
 
Last edited by a moderator:
This is always and only a Windows file permissions issue. You don't have the WINDOWS permissions to do this. Access is (in this case) an innocent bystander. There is nothing you can do from Access. Check with your system administrator or security administrator.
 
This is always and only a Windows file permissions issue. You don't have the WINDOWS permissions to do this. Access is (in this case) an innocent bystander. There is nothing you can do from Access. Check with your system administrator or security administrator.

Well, I actually am one of the sys admins as well, and I checked the permissions on the folder. I have full control on the folder and any subfolders within, as do anyone that would be running this sub. I even went as far as adding the everyone group and giving them full control to the folder with the same reaction. That is why I was thinking there was something else I was doing wrong?
 
Figured it out

I finally realized what I had done wrong, well perhaps not wrong, but the piece I was forgetting.
In the beginning portion of the For-Next loop I was running:

Set ObjTStream = FileSystem.OpenTextFile("D:\Work\TopLevelFolder\" & file.Name, 1)

Normally, I run the FileSystem.GetTextFile command, but this time, I am just opening it. Therein lies the problem, I can't move or delete the item because it is still technically open. So before the MoveFile command I just run:

ObjTStream.Close

Worked like a charm.
 
Whoops - good catch. In this case, you caught a Windows FILE LOCK.
 
I know this is a 12 year old post but i have been stressed to bits trying to work this out for months and stumbled across this today.

THANK YOU!

Works perfectly.
 
Last edited by a moderator:

Users who are viewing this thread

Back
Top Bottom