Skip to content

Commit e3ebcd0

Browse files
RobPasMueanssakthi
andauthored
fix: user install (#479)
Co-authored-by: anssakthi <[email protected]>
1 parent e449972 commit e3ebcd0

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

setup.nsi

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ Name "${PRODUCT_NAME}"
1111
VIProductVersion "${PRODUCT_VERSION}"
1212
OutFile "dist\${OUTFILE_NAME}"
1313

14+
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
15+
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
16+
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
17+
!define MULTIUSER_INSTALLMODE_INSTDIR "ANSYS Inc\$(^Name)"
18+
!define MULTIUSER_INSTALLMODE_COMMANDLINE
1419
!define MULTIUSER_EXECUTIONLEVEL Highest
1520
!define MULTIUSER_MUI
16-
!define MULTIUSER_INSTALLMODE_COMMANDLINE
21+
1722
!include MultiUser.nsh
1823
!include MUI2.nsh
1924
!include InstallOptions.nsh
@@ -45,11 +50,10 @@ FunctionEnd
4550

4651
; Define the installer sections
4752
Section "Ansys Python Manager" SEC01
48-
; Set the installation directory to the program files directory
49-
SetOutPath "$PROGRAMFILES64\ANSYS Inc\Ansys Python Manager"
53+
; Set the installation directory dynamically based on user mode
54+
SetOutPath "$INSTDIR"
5055

5156
; Copy the files from the dist\ansys_python_manager directory
52-
; File /r /oname=ignore "dist\ansys_python_manager\*"
5357
File /r "dist\ansys_python_manager\*"
5458

5559
; Create the start menu directory
@@ -59,36 +63,24 @@ Section "Ansys Python Manager" SEC01
5963
CreateShortCut "$SMPROGRAMS\Ansys Python Manager\Ansys Python Manager.lnk" "$INSTDIR\Ansys Python Manager.exe"
6064

6165
; Add the program to the installed programs list
62-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}"
63-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
64-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$\"$INSTDIR\Ansys Python Manager.exe$\""
65-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "ANSYS Inc"
66-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Version" "${PRODUCT_VERSION}"
67-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${PRODUCT_VERSION}"
66+
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCT_NAME}"
67+
WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$INSTDIR\uninstall.exe"
68+
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$INSTDIR\Ansys Python Manager.exe"
69+
WriteRegStr SHCTX "${UNINSTKEY}" "Publisher" "ANSYS Inc"
70+
WriteRegStr SHCTX "${UNINSTKEY}" "Version" "${PRODUCT_VERSION}"
71+
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayVersion" "${PRODUCT_VERSION}"
72+
WriteRegStr ShCtx "${UNINSTKEY}" $MultiUser.InstallMode 1
6873

6974
WriteUninstaller "$INSTDIR\uninstall.exe"
7075

7176
SectionEnd
7277

73-
; Define the uninstaller section
74-
Section "Uninstall" SEC02
75-
76-
Delete "$PROGRAMFILES64\Ansys Python Manager\*.*"
77-
RMDir "$PROGRAMFILES64\Ansys Python Manager"
78-
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
79-
Delete "$SMPROGRAMS\Ansys Python Manager\Ansys Python Manager.lnk"
80-
RMDir "$SMPROGRAMS\Ansys Python Manager"
81-
Delete "$desktop\Ansys Python Manager.lnk"
82-
SectionEnd
83-
8478
Icon "dist\ansys_python_manager\_internal\assets\pyansys_icon.ico"
85-
InstallDir "$PROGRAMFILES64\ANSYS Inc\Ansys Python Manager"
8679

8780
; Define the custom functions for the MUI2 OneClick plugin
8881
InstProgressFlags smooth
8982
Function oneclickpre
9083
!insertmacro MUI_HEADER_TEXT "Installing ${PRODUCT_NAME}" "Please wait while the installation completes."
91-
; !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
9284
HideWindow
9385
FunctionEnd
9486

uninstall.nsi

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ Var DeleteConfiguration
77

88
; Define the uninstaller section
99
Section "Uninstall"
10-
; Prompt the user to confirm uninstallation
11-
MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure you want to uninstall ${PRODUCT_NAME} ${PRODUCT_VERSION}?" IDYES checkDeleteVenvPath
12-
Abort
13-
14-
checkDeleteVenvPath:
1510
MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to delete the contents in the default virtual environment path location?" IDYES deleteVenvPath
1611
StrCpy $DeleteDefaultVenvPath 0
1712
Goto checkDeleteConfiguration
@@ -30,7 +25,7 @@ deleteConfiguration:
3025
Goto doneAsking
3126

3227
doneAsking:
33-
28+
!include LogicLib.nsh
3429
; Echo the values of $DeleteConfiguration and $DeleteDefaultVenvPath
3530
DetailPrint "User home: $PROFILE"
3631
DetailPrint "DeleteConfiguration: $DeleteConfiguration"
@@ -50,12 +45,16 @@ doneAsking:
5045
RMDir /r /REBOOTOK "$INSTDIR"
5146

5247
; Remove the registry keys
53-
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
48+
DetailPrint "${UNINSTKEY}"
49+
DeleteRegKey SHCTX "${UNINSTKEY}"
5450

5551
; Remove the start menu shortcut and directory
5652
Delete "$SMPROGRAMS\Ansys Python Manager\Ansys Python Manager.lnk"
5753
RMDir /r /REBOOTOK "$SMPROGRAMS\Ansys Python Manager"
5854

55+
; Remove the desktop shortcut
56+
Delete "$desktop\Ansys Python Manager.lnk"
57+
5958
; Display the uninstallation complete message
6059
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} ${PRODUCT_VERSION} has been successfully uninstalled."
6160
SectionEnd

0 commit comments

Comments
 (0)