Old 29th January 2012, 13:28   #1
Acid_Attack
Junior Member
 
Join Date: Aug 2011
Posts: 1
Delete a specific registry data

Hi,

I need to delete a specific registry data inside a value, but not the whole value.
The problem is this:
When the user uninstall there are files that can't be deleted, and therefore we use /REBOOTOK
but if the user re-installed the program before he restarted the machine and then he did the restart, the pending-to-be-deleted-files will be deleted and the program won't work.

For this reason, we want on installation to look inside:
HKLM\SYSTEM\ControlSet\Control\Session Manager "PendingFileRenameOperations"

This key contains the value-data ​​to be deleted after reboot.
But we need to look for the specific value-data and to delete only it and not the whole value (the value contains other files to be deleted)!

Any idea how to do this ?
Acid_Attack is offline   Reply With Quote
Old 2nd February 2012, 15:26   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I believe that is a REG_MULTI_SZ which you can read and write using the Registry plug-in.

Stu
Afrow UK is offline   Reply With Quote
Old 2nd February 2012, 16:18   #3
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
If you rename the file(s) that the uninstaller was unable to delete, then the new files added by the installer won't get deleted by the reboot. (Renaming the files might or might not work, depending upon why you are unable to delete them).

You can try moving the files to a temporary directory if you want to make the install folder look like they were deleted.

Last edited by demiller9; 2nd February 2012 at 16:19. Reason: fixed a typo
demiller9 is offline   Reply With Quote
Old 2nd February 2012, 16:51   #4
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
Quote:
You can try moving the files
you cant move them while they are marked for delete on reboot.
thats one reason they are marked for - in use!

Quote:
"PendingFileRenameOperations"
is a long string sometimes >1024 - so you need the long string special build from nsis.
oh, my watcher limits outout to 730 token, afair this is due the line breaks inbetween that value
Brummelchen is offline   Reply With Quote
Old 2nd February 2012, 17:33   #5
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
I'll have to accept your statement that files listed in PendingFileRenameOperations are locked from being moved, but the code in my installer does it like this:
code:
${If} ${FileExists} C:\Ipls\dlls\*.*
SetOutPath C:\IPLS ; set current dir to prevent deleting C:\Ipls
RMDir /r C:\Ipls ; don't keep any old files or folders
${If} ${FileExists} C:\Ipls\dlls\*.*
; something has held up the folder: rename it to allow fresh files
Rename C:\Ipls\dlls C:\Ipls\dlls.prev
RMDir /r /REBOOTOK C:\Ipls\dlls.prev
${If} ${FileExists} C:\Ipls\dlls.prev\*.*
Push "C:\Ipls\dlls.prev will be deleted after reboot."
Call ErrorLog
${EndIf}
${EndIf}
ClearErrors
${EndIf}

Notice that I don't use the /REBOOTOK switch until after I've tried to remove the files once. Before that logic was added there were always a couple of dlls that wouldn't get deleted. The code above works for us. Now those stubborn files are in a different directory and are safe from the reboot delete.

Here's a second place I do the same thing:
code:
Rename C:\Lockit $Temp\Lockit
RMDir /r /REBOOTOK $Temp\Lockit
${If} ${FileExists} $Temp\Lockit\*.*
Push "$Temp\Lockit will be deleted after reboot."
Call ErrorLog
${EndIf}

There are always a couple of files in that folder that can't get deleted (dlls used by Windows Explorer and the Logon process). The code above works.

Last edited by demiller9; 2nd February 2012 at 17:38. Reason: Added a second code snippet
demiller9 is offline   Reply With Quote
Old 2nd February 2012, 20:37   #6
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
similar to mine
http://forums.winamp.com/showthread.php?t=340940
Brummelchen is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump