Announcement

Collapse
No announcement yet.

Add or Remove Programs - Size missing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add or Remove Programs - Size missing

    Hi all,

    I seem to have lost the Size attribute in the Add or Remove Programs list (XP).

    The projected install size still appears in the setup (in the directory page).

    I've tried removing the SectionSetSize calls to see if that might be causing it, but the size still won't show up in Add or Remove Programs. I know it should, but I don't know if it's something I did or a bug. Probably the former.

    Where else can you save/store the size in a *.nsi script?

    Using or not using AddSize also isn't responsible.

    Many programs don't have a size in Add or Remove, and I don't consider it very important. Just puzzling...

  • #2
    AddSize or SectionSetSize have nothing to do with the Add/Remove Control Panel. Raymond Chen had a blog entry about the size attribute in there. It should shed some light on what's happening there. To sum it up, you should write the number of KBs into EstimatedSize in your uninstall key in the registry.
    NSIS FAQ | NSIS Home Page | Donate $
    "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

    Comment


    • #3
      There must be more to it than meets the eye. Size is conspicuous only by its absence in Add/Remove Programs.

      EstimatedSize was worth a try though. Thx.

      Comment


      • #4
        The way it appears to me, is that windows checks the parent directory of the uninstaller and uses this directory size for display.

        I currently have my uninstaller.exe in c:\temp
        with the registry setting uninstallstring pointing to c:\temp\uninstall.exe. If i add for example a 100MB program into c:\temp - windows add/remove programs size increases by 100MB.

        If i place the uninstaller into c:\ - and update the string to point to the new path c:\uninstall.exe - i no longer get a size, due to having no parent folder.

        The size shown in add/remove programs seems to be the "size on disk" amount from folder properties.

        Comment


        • #5
          Windows uses an algorithm to compute the size (imprecisely a lot of the time). Sometimes the parameters sought by the algorithm which derive from the name of your program and the files that are installed, are not present, so it would seem. According to the blog mentioned by Kichik (see above), you are able in such an event to override the algorithm by including your own dword in the reg that gives the exact size in KB: EstimatedSize.

          To the annoyance of many, the dword value only applies if you install your software using an MSI installer. A search I did yesterday indicates that people have been trying without success to use EstimatedSize for some time; it only works with MSI.

          In short, you can get the size by making sure the size algorithm finds the file/folder names it needs, or give up.

          Comment


          • #6
            It works fine for me?
            NSIS 2.45, Windows 7

            Here are the relevant bits from my foo.nsi

            code:

            [...]

            !define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"

            !include "FileFunc.nsh" ; for ${GetSize} for EstimatedSize registry entry

            [...]

            Section "Install"

            ; [...copy all files here, before GetSize...]

            ; get cumulative size of all files in and under install dir
            ; report the total in KB (decimal)
            ; place the answer into $0 (ignore $1 $2)
            ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2

            ; Convert the decimal KB value in $0 to DWORD
            ; put it right back into $0
            IntFmt $0 "0x%08X" $0

            ; Create/Write the reg key with the dword value
            WriteRegDWORD HKLM "${ARP}" "EstimatedSize" "$0"

            [...write the other reg keys in ${ARP}...]

            SectionEnd

            [...]

            Comment


            • #7
              ${GetSize} gets the real size, as opposed to the size on disk. As I understand it, the Add/Remove programs number, if done correctly, is the size on disk, the size needed by the software before running out of disk space in the worst case situation. The size on disk value varies according to the file system, FAT32 or NTFS, and the drive's cluster size apparently.

              The NSIS documentation does not clearly state which of the two sizes the installer automatically calculates to determine the Space Required.

              Maybe someone, who has that knowledge, could provide an answer. My guess is it's the real size.

              Comment


              • #8
                I had an idea -- a cut-and-paste job, like most of my ideas are. To obtain the size on disk, you can modify "GetSize" in FileFunc.nsh.

                For documentation, see the NSIS user manual: E.1.3 GetSize.
                Three variables are returned,

                $var1 ; Result1: Size on disk
                $var2 ; Result2: Sum of files
                $var3 ; Result3: Sum of directories

                PHP Code:
                ...

                    
                Push $8
                    Push 
                $9
                    
                insert code
                    Push $R1
                    Push $R2
                    
                end insert
                    Push $R3
                    Push $R4

                ...

                    
                FileFunc_GetSize_file:
                    
                StrCpy $R6 0
                    StrCmp 
                $5$'' +3
                    IntOp $R4 $R4 
                1
                    
                goto FileFunc_GetSize_findnext
                    FileOpen 
                $'$R8\$R7' r
                    IfErrors 
                +3
                    FileSeek 
                $9 0 END $R6
                    FileClose 
                $9
                    StrCmp 
                $'' +2
                    IntCmp $R6 
                $5 0 FileFunc_GetSize_findnext
                    StrCmp 
                $'' +2
                    IntCmp $R6 
                $6 0 0 FileFunc_GetSize_findnext
                    IntOp $R4 $R4 
                1
                    
                insert code
                    IntOp $R6 $R6 
                4096
                    IntOp $R1 $R6 
                4096
                    StrCmp $R1 0 0 
                +2
                    StrCpy $R1 4096
                    IntOp $R2 4096 
                $R1
                    IntOp $R6 $R6 
                4096
                    IntOp $R6 $R6 
                $R2
                    
                end insert
                    System
                ::Int64Op $R3 $R6
                    Pop $R3

                ...

                    
                Pop $R4
                    Pop $R3
                    
                insert code
                    Pop $R2
                    Pop $R1
                    
                end insert
                    Pop 
                $9
                    Pop 
                $8

                ... 
                Size on disk is valid on NTFS formatted drives. All credit for the original "GetSize" goes to KichiK -- Function "FindFiles".

                Comment


                • #9
                  For Windows XP, I found that the only way to make Add/Remove display the estimated size was to also write the DWORD "WindowsInstaller" 1 - then it shows up. I don't know what other consequences are of setting that DWORD as we just discovered it a few minutes ago and are still testing.

                  edit: Dammit, now the presense of "WindowsInstaller" 1 is preventing the entry from showing entirely. Why is this so convoluted?
                  Last edited by CrushBug; 3 June 2010, 23:42. Reason: further pain discovered

                  Comment


                  • #10
                    Is there any solution?
                    I write all uninstall information in HKLM ...\Uninstall. But it doesn't appear in Add/Remove software.
                    I use Windows XP SP2.
                    I read all information, but i don't get it. Has someone a clear solution?`
                    Thx

                    Comment


                    • #11
                      Did you miss the last post?

                      Stu

                      Comment


                      • #12
                        You should not be setting WindowsInstaller=1, it is a undocumented value and we don't know what it does
                        IntOp $PostCount $PostCount + 1

                        Comment


                        • #13
                          !DISCLAIMER!
                          This data is based on an undocumented registry entry and is only verified on Windows XP and is subject to change.
                          In Addition, the example only lists 32bit installations unless you tweak it to read from the 64bit registry.


                          Here's what I know...

                          Add and Remove Programs dialog lists the Size based from the corresponding ArpCache registry entry.

                          for example here is the my machines Notepad++ ArpCache Entry
                          PHP Code:
                          Windows Registry Editor Version 5.00

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\Notepad++]
                          "SlowInfoCache"=hex:28,02,00,00,01,00,00,00,00,50,ae,00,00,00,00,00,64,22,d7,\
                            
                          82,ab,ae,cb,01,00,00,00,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,\
                            
                          61,00,6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,4e,00,6f,00,74,00,65,\
                            
                          00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,6f,00,74,00,65,00,70,00,61,00,\
                            
                          64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
                            
                          00,00,00,00,00,00,00,00
                          "Changed"=dword:00000000 
                          The important entry here is the "SlowInfoCache" value.

                          There is a pretty good and short article explaining it here: http://www.pcmag.com/article2/0,2817,1173443,00.asp

                          Here is an example of reading the data:

                          PHP Code:
                          !include "LogicLib.nsh"

                          OutFile Test.exe
                          ShowInstDetails show

                          Section
                              
                          ## Open Registry Key
                                  
                          System::Call "Advapi32::RegOpenKeyEx(i 0x80000002,t 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\Notepad++',i 0,i 1,*i .r0)i .r3"
                                  
                          ;DetailPrint "Result=$3"
                                  
                          ${IfNotThen} $${|} Abort "Not ARPCache data is available." ${|}
                              
                              
                          ## Check for existance of SlowInfoCache and validate tpye and size
                                  
                          System::Call "Advapi32::RegQueryValueEx(i r0,t 'SlowInfoCache',i 0,*i .r4,i 0,*i .r5)"
                                  
                          ${IfNotThen} $0   ${|} Abort "Not SlowInfoCache data is available." ${|}
                                  ${
                          IfNotThen} $3   ${|} Abort "SlowInfoCache type is unexpected" ${|}
                                  ${
                          IfNotThen} $552 ${|} Abort "SlowInfoCache size unexpected"        ${|}
                              
                              
                          ## Read SlowInfoCache Data
                                  
                          System::Alloc $5
                                  Pop 
                          $6
                                  System
                          ::Call "Advapi32::RegQueryValueEx(i r0,t 'SlowInfoCache',i 0,*i n,i r6,*i r5)"
                                  
                          ${IfNotThen} $0   ${|} Abort "Error reading SlowInfoCache data" ${|}
                                  
                          System::Call '*$6(&i4 .R1,&i4.R2,&i8.R3,&i4 .s,&i4 .s,&i4 .R5,&w524 .R6)'
                                  
                              
                          ## Convert the LastUsed FileTime to a Human readable format
                                  
                          System::Call `*(&i4 s,&i4 s)i .r7`
                                  
                          System::Free $6
                              
                                  System
                          ::Call "*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r3"
                                  
                          System::Call "Kernel32::FileTimeToSystemTime(i $7, i r3)"
                                  
                          System::Call "Kernel32::GetDateFormatA(i 0,i 0,i r3,t 'MM/dd/yyyy',t .R4,i ${NSIS_MAX_STRLEN})"
                                  
                          System::Free $7

                              
                          ## Close Registry Key
                                  
                          System::Call "Advapi32::RegCloseKey(i r0)i .r3"
                                  
                          ${IfNotThen} $${|} Abort "Unable to close registry key" ${|}
                                  
                              
                          ## Format the InstallSize into a human readable format [bytes to megabytes]
                                  
                          Math::Script "R3=ff(R3/1048576.0,18)+' MB'"
                                  
                              
                          ## Display Results
                                  
                          DetailPrint "cbSize=$R1"
                                  
                          DetailPrint "HasName=$R2"
                                  
                          DetailPrint "InstallSize=$R3"
                                  
                          DetailPrint "LastUsed=$R4"
                                  
                          DetailPrint "Frequency=$R5"
                                  
                          DetailPrint "Name=$R6"
                          SectionEnd 
                          The Frequency value is an indication of the times the program is executed from a traceable shortcut from the Start Menu or Desktop. On the Add & Remove Programs dialog this is expressed as "Rarely", "Occasionally", or "Frequently". I'm not sure what values trigger what title but It could be calculated by tweaking a know value by increments. I think this is also tied to the LastUsed date so it might not be as simple hard value ranges.
                          Regards ^_^

                          Search the Forums and the Wiki

                          Comment


                          • #14
                            Yep, the code KEYofR posted works (for me too) under win 7.

                            here is it again:

                            code:

                            !include "TextFunc.nsh"
                            ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
                            IntFmt $0 "0x%08X" $0 #< conv to DWORD
                            WriteRegDWORD ${APP_UNINST_ROOT_KEY} "${APP_UNINST_KEY}" "EstimatedSize" "$0"

                            Later, in few days, I will test it on XP also.

                            Thanks

                            Comment


                            • #15
                              Originally Posted by imgarfield View Post
                              Yep, the code KEYofR posted works (for me too) under win 7.

                              here is it again:

                              code:

                              !include "TextFunc.nsh"
                              ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
                              IntFmt $0 "0x%08X" $0 #< conv to DWORD
                              WriteRegDWORD ${APP_UNINST_ROOT_KEY} "${APP_UNINST_KEY}" "EstimatedSize" "$0"

                              Later, in few days, I will test it on XP also.

                              Thanks
                              It seems to work under XP also.

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎