Sign in to follow this  
Followers 0
Champak

Dll deletion problem after object creation

6 posts in this topic

#1 ·  Posted (edited)

I'm trying to delete a dll after an uninstall, but it wont delete. Code:

$PIDDLL1 = Run('Regsvr32 /s /u "' & $CommDLL & '"')
        ProcessWaitClose($PIDDLL1)

        FileDelete ( $CommDLL )oÝ÷ Ø Ý#ozÚâyÖ®¶­sb'VåvBb33µ&Vw7g#3"÷2÷RgV÷C²b33²fײb33c´6öÖÔDÄÂfײb33²gV÷C²b33² ¢fÆTFVÆWFRb33c´6öÖÔDÄÂ

Also note, I don't have this problem if I just do a straight delete without unregistering the file.

EDIT: Changed title

Edited by Champak

Share this post


Link to post
Share on other sites



Bump....this isn't making sense.

Share this post


Link to post
Share on other sites

OK, here is what I realized, the problem with this isn't the unregister, it is because the the dll was created in an object. So in case people have tried this and said "it works for me", it is because you may have tried it and without creating the object. So here is the updated code that doesn't work...even if I zero out the variable that is pointing to the file, the file still wont delete:

$oDLL = ObjCreate("dll file")
oDLL  = 0
FileDelete ( "dll file" )

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$oDLL = ObjCreate("dll file")
oDLL  = 0
FileDelete ( "dll file" )
Is you dll anything that hooks into the Windows Shell? If so, explorer isn't always very

timely about releasing shell extensions. I have a program with a shell extension and

I use Inno Setup for the installer. Even though the .dll has the 'regserver' attribute

and is unregistered during the uninstall, I found that if I call my own function to also

unregister the server, then sometimes the shell will let the file be deleted during

the uninstall. Sometimes the user has to log out, then log back in.

It may be easier just to mark the file for deletion on the next boot or login.

Edit:

You could also try adding the line

EnvUpdate()

to attempt to flush the registry info

Also your process is in memory and that's the one that got the ref to the

object. I don't know how snappy AutoIt is about releasing references, if

there's a cache or whatever, but Windows itself hasn't shown to be that

snappy in my experience. Try deleting the dll after you close the process

that uses it.

Edited by MilesAhead

Share this post


Link to post
Share on other sites

1/ I don't know if it is a windows shell. It is three separate dlls and all of them are causing the same problem...so I'll just assume they are all windows shell.

2/ EnvUpdate ( ) doesn't work

3/ I tried deleting the dll after the process closes...OP...that doesn't work, unless I'm confused about that function.

I may just end up making an independent uninstall app...which I really didn't want to do, or your suggestion on deleting it on reboot....can I get a link on that.

Share this post


Link to post
Share on other sites

I may just end up making an independent uninstall app...which I really didn't want to do, or your suggestion on deleting it on reboot....can I get a link on that.

I think I would go with using Inno Setup. It's free, has been around awhile and for COM dlls

you just add the attribute of regserver and it will register at install and unregister during

removal. Also as I mentioned if you make an InitializeUninstall script to unregister the server,

the double hit avoids the user having to log off or reboot most of the time.

In my script if the install folder is not able to be deleted I pop up a msg dialog suggesting the user

log out, then log back in, and delete the install folder. It's a lot less annoying than having the

user reboot. See if log off works in your situation.

If not, it's a Windows quirk. Not really your fault if Windows doesn't handle COM stuff gracefully.

Inno Setup is pretty easy to start using right away and has Pascal like scripting to write your

user functions such as InitializeUninstall. It also has an [uninstall run] section so for example

if you want to clear out user settings in AppData or whatever, you can tell it to delete the settings

folder after uninstall. Very nice tool.

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