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

Reply
Thread Tools Search this Thread Display Modes
Old 11th August 2013, 19:29   #1
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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"
anderci is offline   Reply With Quote
Old 12th August 2013, 14:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Are you doing StrCpy $DATADIR "C:\Users\Public\Clark_Anderson\${MUI_FILE}" in the uninstaller?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 12th August 2013, 16:51   #3
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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
anderci is offline   Reply With Quote
Old 12th August 2013, 17:06   #4
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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?
anderci is offline   Reply With Quote
Old 12th August 2013, 18:13   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 12th August 2013, 18:42   #6
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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.
anderci is offline   Reply With Quote
Old 12th August 2013, 19:32   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 12th August 2013, 20:10   #8
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
By 'No variables are saved.' do you mean 'developer created variables' as differentiated from those like $INSTDIR
anderci is offline   Reply With Quote
Old 13th August 2013, 01:23   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
$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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th August 2013, 01:48   #10
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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.
anderci is offline   Reply With Quote
Old 14th August 2013, 15:07   #11
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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.
anderci is offline   Reply With Quote
Old 15th August 2013, 17:40   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
That looks like you're setting $DATADIR to a path which is only valid for your build machine. Why?

Stu
Afrow UK is offline   Reply With Quote
Old 15th August 2013, 19:47   #13
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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.
anderci is offline   Reply With Quote
Old 16th August 2013, 23:04   #14
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 17th August 2013, 00:30   #15
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
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}"
anderci is offline   Reply With Quote
Old 17th August 2013, 11:21   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 17th August 2013, 12:53   #17
anderci
Junior Member
 
Join Date: Nov 2012
Location: Colorado
Posts: 41
Stu

Thank you very much.
I found 4.9.2.7 ExpandEnvStrings
anderci 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