Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 8th August 2019, 11:37   #1
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
${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!!!
DivyaArun is offline   Reply With Quote
Old 8th August 2019, 17:13   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
/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.

IntOp $PostCount $PostCount + 1
Anders 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