Skip to content
⌘ NSIS Forum Archive

${GetSize} not always giving the exact size of the installed path

2 posts

DivyaArun#

${GetSize} not always giving the exact size of the installed path

Hi,

I need to display the installed folder size in the Add/Remove programs. I have tried the below code. I noticed that most of the times when I run the installer, it gives 0 as the size, sometimes 70 KB which I believe is the uninstall.exe size. Only once it gave me the correct size. I am confused what is happening behind the scenes.
!define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
Section "Install"

SetOutPath $INSTDIR
SetOverwrite ifnewer
File "1.bat"
File "2.bat"
File "3.bat"
SetOverwrite try
SetOutPath $INSTDIR\con
File "con\1.dll"
File "con\2.dll"
File "con\3.dll"
File "con\4.dll"
File "con\5.dll"
File "con\6.dll"

SetOutPath $INSTDIR

${GetSize} "INSTDIR" "/S=0M /G=0" $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"
MessageBox MB_OK "$0"

Some of the alternatives I tired
a) Putting Sleep thinking that it might take some time to read the size.
b) Moving the GetSize code to Section --Post as well as tried calling from another section
c) When I hard code some inner directories, it gives the exact size. Ex- Installdir\con. However, I need to get the total size of the InstallDir.

Please help!!!
Anders#
/G=0 means don't search subfolders, is this what you want?

The IntFmt is pointless, DWORD is a integer type, not a string format. You can just write a normal decimal number to the registry.