Using the EstimatedSize value inside a program uninstall key to correctly display the program size in the Add/Remove Programs list

一曲冷凌霜 提交于 2019-12-07 12:55:30

I figured out that changing the value of EstimatedSize under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{my-guid-value}

does not have any direct effect. This value is cached in the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\{my-guid-value}\SlowInfoCache

Only after I remove (rename) this SlowInfoCache value, the updated size appears under Add or remove programs.

Regards, divo

user214888

Writing an arbitrary value works fine for me on Windows7.

I use NSIS which does not automatically fill this value or write this key or do anything magical here. But you can create the registry keys yourself, and put whatever you want in them yourself, using ordinary script commands.

This is NSIS *.nsi script, sorry, but there's only 3 active lines. I don't think you have to know NSIS to see that I'm just creating the key arbitrarily and writing a value of my choice into it. I can tell you also that, when I was putting bad values in there, it sure showed up in add/remove programs exactly as bad as what I'd written. (I assumed the value was supposed to in Bytes at first, So, my 3.2 MB app showed up as 3.2 GB)

excerpt from foo.nsi :

    [...]

    ; ARP = just convenience variable to hold the long reg key path
    !define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"

    ; include a function library that includes a file/directory size reporting command
    !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  ($1 and $2 get other info we don't care about)
    ${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 keys in the same reg path...]

    SectionEnd

    [...]
Carlos

Although this topic is quite old, a search took me here while looking for how to show the application size in the add/remove programs window in Windows XP, so I post what I found just in case somebody else find it useful:

Just go to the folder of your application under:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\{app_name}

and add an alphanumeric value called "InstallLocation" whose value is the main folder of your application.

If your are doing it manually (not during installation), in order to make it work you have to remove folder:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\\{app_name}

because it caches the uninstall information.

What kind of installer did you use? MSI?

Windows Installer will determine and set this value during installation (see MSDN: Uninstall Registry Key)

I think it is not possible to manually set this value. There is a lot going on (some really "lame" stuff) behind the scenes (http://blogs.msdn.com/oldnewthing/archive/2004/07/09/178342.aspx)

Regards, divo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!