Champak Posted July 30, 2008 Share Posted July 30, 2008 (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 August 1, 2008 by Champak Link to comment Share on other sites More sharing options...
Champak Posted July 31, 2008 Author Share Posted July 31, 2008 Bump....this isn't making sense. Link to comment Share on other sites More sharing options...
Champak Posted August 1, 2008 Author Share Posted August 1, 2008 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" ) Link to comment Share on other sites More sharing options...
MilesAhead Posted August 1, 2008 Share Posted August 1, 2008 (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 August 1, 2008 by MilesAhead My Freeware Page Link to comment Share on other sites More sharing options...
Champak Posted August 1, 2008 Author Share Posted August 1, 2008 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. Link to comment Share on other sites More sharing options...
MilesAhead Posted August 1, 2008 Share Posted August 1, 2008 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. My Freeware Page Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now