Archive: uninstall does not remove $DATADIR (app data) from 64 bit windows systems


uninstall does not remove $DATADIR (app data) from 64 bit windows systems
I think I did a poor job of asking my question in another thread.
( NSIS Develop, Deploy 32 bit applications to 64 bit Windows? )
My NSIS script successfully installs my 32 bit apps on both 32 and 64 bit windows systems.
They can run successfully on both.

The problem is the uninstall process leaves the application data behind.

x64 requires two 'install directories', one for the app and one for any data created by the app (including its .ini file) In addition to the $INSTDIR variable, I defined another: $DATADIR
What am I missing?
Here are parts of the script that almost works:

var DATADIR
:
:
Function .onVerifyInstDir
${If} ${RunningX64}
${Else}
StrCpy $DATADIR $INSTDIR
${EndIf}
FunctionEnd
:
:
:
!define MUI_WELCOMEPAGE
!define MUI_LICENSEPAGE
!define MUI_DIRECTORYPAGE

!define MUI_ABORTWARNING
!define MUI_UNINSTALLER
!define MUI_UNCONFIRMPAGE
!define MUI_FINISHPAGE

Function .onInit
${If} ${AtLeastWinVista}
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES32\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
${Else}
StrCpy $INSTDIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
${EndIf}
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "$PROGRAMFILES\Clark_Anderson\${MUI_FILE}"
${EndIf}
FunctionEnd
:
:
:
Section "Sample Data Files (Optional: Recommended for starting)"
SectionIn 2
SetOutPath "$DATADIR\DataBases"
:
:
SectionEnd

Section "Uninstall"
:
:
:
:
;Delete Files
Delete "$INSTDIR\*.*"
Delete "$DATADIR\Reports\Templates\*.*"
Delete "$DATADIR\Reports\*.*"
Delete "$DATADIR\DataBases\*.*"
Delete "$DATADIR\ExpImport\*.*"
Delete "$DATADIR\*.*"

;Remove the installation directory
RMDir /r "$INSTDIR"
RMDir /r "$DATADIR\Reports\Templates\*.*"
RMDir /r "$DATADIR\Reports\*.*"
RMDir /r "$DATADIR\DataBases\*.*"
RMDir /r "$DATADIR\ExpImport\*.*"
RMDir /r "$DATADIR"


Are you doing StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}" in the uninstaller?


Thank you for responding.
No I am depending only on the definition in:

Function .onInit
${If} ${AtLeastWinVista}
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES32\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
${Else}
StrCpy $INSTDIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
${EndIf}
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\Clark_Anderson\${MUI_FILE}"
StrCpy $DATADIR "$PROGRAMFILES\Clark_Anderson\${MUI_FILE}"
${EndIf}
FunctionEnd

followed by:

Function .onVerifyInstDir
${If} ${RunningX64}
${Else}
StrCpy $DATADIR $INSTDIR
${EndIf}
FunctionEnd


I have tried out modifying the

Function .onInit
:
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
to
StrCpy $DATADIR "$APPDATA\Clark_Anderson\${MUI_FILE}"

but that seems to have sent the app data folders and files to:
C:\Users\Administrator\AppData\Roaming\Clark_Anderson\SurvyMgr

I have not been able to 'see' those data folders and files after the install and cannot confirm if they were successfully uninstalled.


Also, I tried changing ShowUninstDetails "nevershow" to "show" or show

The details went by so fast I could not hope to read them. Are there any ideas to allow me to examine uninstall details?


You have to restore $datadir in the uninstaller, variables are not saved for you but like I already said, it does not make sense that this is a x64 only thing...


Thank you,

Is it that NSIS built-in variables are saved for uninstall, but developer created variables are not?

Are Push and/or Pop commands of any use with this?

For all 32 bit windows installations, I can and do define the $DATADIR == $INSTDIR

For 64 bit windows installations, the $INSTDIR for 32 bit applications MUST be in the C:\Program Files (x86)\... folder structure. The data MUST be elsewhere.
A Microsoft help line representative recommended the C:\Users\Public\... folder structure.


No variables are saved.

You can put readonly data in $programfiles, data written to by users should go somewhere else but that is true for all NT systems, also on 32bit Windows...


By 'No variables are saved.' do you mean 'developer created variables' as differentiated from those like $INSTDIR


$exedir/path and $instdir are set in the uninstaller before .oninit but $instdir is just the same as the folder the uninstaller is in unless it was started with a special parameter.


Thank you.

I was about to say 'I wish I understood this better', but maybe the uninstaller knows about $INSTDIR merely because it is local to the uninstaller program.

A little bit discouraging. I guess, until a better idea comes, I will need to but the defining of $DATADIR in the uninstall section, also.


An additional part of the solution from http://forums.winamp.com/showthread.php?t=220552
One of my applications uses only one subdirectory of the $DATADIR and required the:
SetOutPath "$TEMP" in the Section "Uninstall" as well as the separate:

${If} ${RunningX64}
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
${Else}
StrCpy $DATADIR $INSTDIR
${EndIf}
definition.

Now the uninstall works completely for 32 bit and 64 bit Windows!
Thank you.


That looks like you're setting $DATADIR to a path which is only valid for your build machine. Why?

Stu


Stu,

If ${AtLeastWinVista}, Windows has established the C:\Users\Public\... folder structure. This structure is available to anyone on the PC.

'Some real help came from lengthy phone conversations with very patient Microsoft
Windows 7 Customer Support agents. They were not programmers, but I learned
enough from them to figure the rest out.'

Windows 7 x64 has a system variable/constant: PUBLIC=C:\Users\Public
I have not tested, but I think Vista and Win7 have the same definition for PUBLIC.

I have not, yet, found a similar $PUBLIC defined in NSIS.

For Pre-Vista Windows I put everything in the ProgramFiles=C:\Program Files\... folder structure or D:\Program Files\... folder structure or E:\Program Files\... folder structure

I wrote a small VB6 function to identify which of the Windows variables (ProgramFiles(x86), PUBLIC, ProgramData) and set a variable (replacing App.Path) accordingly.

Multiple instances of one of my freeware applications is sometimes used with a shared database located on the LAN.

I hope this answers your question.


ReadEnvStr $DATADIR PUBLIC

Never hard code such paths. Windows installed with other languages will not necessarily have that path.

Edit: I have checked and the PUBLIC environment variable exists on Vista and above.

Stu


Stu,
Thank you. I use the PUBLIC Environment Variable in my VB program.

In the NSIS script, I replaced
StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}"
with
ReadEnvStr $DATADIR PUBLIC\Clark_Anderson\${MUI_FILE}
I must be doing something wrong, because $DATADIR ended up blank.
Must I do it: ReadEnvStr $DATADIR PUBLIC"\Clark_Anderson\${MUI_FILE}"
or: ReadEnvStr $DATADIR PUBLIC
StrCpy $DATADIR $DATADIR"\Clark_Anderson\${MUI_FILE}"


ReadEnvStr requires the environment variable name. If you have a path, use ExpandEnvStrings:

ExpandEnvStrings $DATADIR `%PUBLIC%\Clark_Anderson\${MUI_FILE}`

If in doubt, always check the manual.

Stu


Stu

Thank you very much.
I found 4.9.2.7 ExpandEnvStrings