Jump to content

Delete File that is in use by a process


Recommended Posts

Hi there,

I noticed that the FileDelete() function does not delete files when they are in use by another process. So my question is, is there a way to delete files that are in use by another process?

Thanks,

MrNoJK

Link to comment
Share on other sites

Try to delete them using operating system commands. They won't delete them. So why should AutoIt?

To delete such files you either have to wait for the locking process to terminate or you write a key to the registry and delete the file at next system startup.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Try to delete them using operating system commands. They won't delete them. So why should AutoIt?

To delete such files you either have to wait for the locking process to terminate or you write a key to the registry and delete the file at next system startup.

So you are actually saying that it is not possible to immediately delete a file that is in use by another process, without terminating it?

Link to comment
Share on other sites

That's how I understand it. The file is locked for a reason.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You might want to try unlocker.exe and forcedelete.exe - I am not sure, but they might resolve the issue

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I put together a little for this some time ago, maybe you can try your luck.

I had a look at the source you posted, and it looks like it is very well capable of doing what I want it to do. But, your function 'Unlock()' for example uses a lot of data that it grabs from your specific GUI. Now my question is, do you have a global 'Unlock()' function where you for example just have to pass some parameters to specify which file needs to be unlocked?

~MrNoJK

Link to comment
Share on other sites

I had a look at the source you posted, and it looks like it is very well capable of doing what I want it to do. But, your function 'Unlock()' for example uses a lot of data that it grabs from your specific GUI. Now my question is, do you have a global 'Unlock()' function where you for example just have to pass some parameters to specify which file needs to be unlocked?

~MrNoJK

No I do not have a global unlock function that you can just pass the handle information to and unlock the file, but you can easily make one though.

Try playing with this, might be something like what you describe?

<BAD CODE GOES HERE>

Edit: fixed a serious amount of typos, also, more info on this stuff here.

Edited by THAT1ANONYMOUSDUDE
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...