Jump to content

Access Is Denied Deleting A File.


Recommended Posts

Occasionally I need to delete a file and this works 99% of the time. Once in a while I can't delete the file as the OS (XP) tells me that access is denied as the file is in use by another process. I can't for the life of me identify who that process is so I sometimes have to reboot to get back my legitimate access to the file.

Is there anyway in AutoIT of identifying the process that has the file opened? Under normal conditions the file is read and closed without a problem. I've checked all of my .Net code and I can see no exceptions raised during the open and close process so I'm wondering if some internal OS resource is still preventing the file from being deleted.

Any ideas?

Link to comment
Share on other sites

i dont know the exact answer, however maybe give this a try

; Reduce memory usage
; Author wOuter ( mostly )

Func _ReduceMemory($i_PID = -1)
    
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

just an idea

8)

NEWHeader1.png

Link to comment
Share on other sites

not really answering your question but i've read that windows indexing service can lock files. just curious do you have that running?

edit: sorry valuater i didn't mean to "step" on you (thats what its called in amateur radio)

Edited by pecloe
Link to comment
Share on other sites

Valuater: I'll bear your code fragment in mind but I think pecloe might have hit this on the head as I've not had the problem for a few days now. I was concerned last week about some services in XP that suddenly wake up and nuke my response and spin around 90-100% cpu time. One of them cisvc.exe was a notable culprit and that puppy does the indexing service. I turned it off and I wonder if that might not have been the problem all along?

I'll monitor it over the next few days and see if my deletes are stable again. Thanks, both, for your quick response.

Link to comment
Share on other sites

I downloaded it, created a directory for it, did the install.bat to regsvr32 it but when I run it, does nothing it!

I opened a file and I tried running WhoLockMe.exe in a DOS command window using the file as the parameter but it returns immediately and displays nothing. Am I doing something wrong with it?

Link to comment
Share on other sites

I downloaded it, created a directory for it, did the install.bat to regsvr32 it but when I run it, does nothing it!

I opened a file and I tried running WhoLockMe.exe in a DOS command window using the file as the parameter but it returns immediately and displays nothing. Am I doing something wrong with it?

It adds an option on the context menu. Right click on the file that it locked and select 'Who Locked Me?'.

That it how it's supposed to be used.

I don't use it, I just knew about it and thought it would help.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

It adds an option on the context menu. Right click on the file that it locked and select 'Who Locked Me?'.

That it how it's supposed to be used.

I don't use it, I just knew about it and thought it would help.

It's sort of ironic given the nature of the product but I could not delete WhoLockMe! Fortunately, Ebenezer's link to the other unlocker did manage to delete WhoLockMe. :think:

So Ebenezer saves the day. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...