Sign in to follow this  
Followers 0
MrNoJK

Delete File that is in use by a process

9 posts in this topic

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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?

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Edited by ApudAngelorum

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

wow, I'm sorry, I just decided to actually test that code and I noticed that I did something wrong, the handle wasn't being closed because I forgot to close it, and I was duplicating the handle of the handle I had previously duplicated :S

File Unlocker.au3


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
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
Sign in to follow this  
Followers 0