77RequestExecutionLevel admin
88
99; ---------------------------------------------
10-
1110Section " MainInstallation"
1211 DetailPrint " Starting AroCrypt installation..."
1312 DetailPrint " Setting installation directory to: $INSTDIR"
14-
13+
1514 SetOutPath " $INSTDIR"
1615 DetailPrint " Copying application files..."
1716
@@ -22,12 +21,14 @@ Section "MainInstallation"
2221
2322 ; File association for .arocrypt files
2423 DetailPrint " Setting up file associations..."
25- DetailPrint " Registering .arocrypt file extension..."
2624 WriteRegStr HKCR " .arocrypt" " " " AroCryptFile"
2725 WriteRegStr HKCR " AroCryptFile" " " " AroCrypt File"
2826 WriteRegStr HKCR " AroCryptFile\DefaultIcon" " " " $INSTDIR\resources\other_images\file_icon.ico"
2927 DetailPrint " File associations configured successfully"
30-
28+
29+ ; Mark install as completed
30+ WriteRegStr HKCU " Software\AroCrypt" " Installed" " 1"
31+
3132 DetailPrint " Main installation completed"
3233SectionEnd
3334
@@ -39,63 +40,63 @@ SectionEnd
3940
4041Function InstallRootCertificate
4142 DetailPrint " Preparing to install AroCrypt root certificate..."
42- DetailPrint " Creating temporary directory for certificate..."
43-
4443 SetOutPath " $TEMP\AroCrypt"
45- DetailPrint " Extracting certificate file..."
4644 File /oname= arocrypt.crt " C:\Users\AroCodes\Desktop\Projects\arocrypt\certs\arocrypt.crt"
47- DetailPrint " Certificate file extraction completed"
48-
49- DetailPrint " Certificate file extracted, proceeding with installation..."
50- DetailPrint " Installing certificate to Windows certificate store..."
51-
52- ; Use ExecWait with proper error checking
5345 ExecWait ' certutil.exe -addstore "Root" "$TEMP\AroCrypt\arocrypt.crt"' $0
54-
46+
5547 ${If} $0 != 0
56- DetailPrint " Certificate installation failed with error code: $0"
57- DetailPrint " Certificate installation is critical for AroCrypt to function properly."
58- MessageBox MB_OK |MB_ICONSTOP " Certificate installation failed! AroCrypt requires the root certificate to be installed. Please try running the setup as an administrator. If the issue persists, contact the developer at arocodes@gmail.com for further assistance. ERROR_CODE: INV_CERT"
48+ MessageBox MB_OK |MB_ICONSTOP " Certificate installation failed! Please run as admin. ERROR_CODE: INV_CERT"
5949 Quit
60- ${Else}
61- DetailPrint " Certificate installed successfully to Windows certificate store"
6250 ${EndIf}
63-
64- DetailPrint " Cleaning up temporary certificate file..."
51+
6552 Delete " $TEMP\AroCrypt\arocrypt.crt"
6653 RMDir " $TEMP\AroCrypt"
67- DetailPrint " Certificate installation process completed successfully"
68- DetailPrint " Proceeding with installation..."
69-
54+ DetailPrint " Certificate installed successfully"
7055Return
7156FunctionEnd
7257
7358; ---------------------------------------------
7459Section " Uninstall"
7560
76- ${If} ${FileExists} " $INSTDIR\AroCrypt.exe"
77- DetailPrint " Removing application files..."
78- RMDir /r " $INSTDIR"
79- DetailPrint " Application files removed"
80- DetailPrint " Uninstallation completed successfully"
81- ${Else}
82- DetailPrint " Removing file associations..."
83- DeleteRegKey HKCR " .arocrypt"
84- DeleteRegKey HKCR " AroCryptFile"
85- DetailPrint " File associations removed"
61+ ReadRegStr $0 HKCU " Software\AroCrypt" " Updating"
62+ StrCmp $0 " 1" isUpdate
8663
87- DetailPrint " Starting AroCrypt uninstallation... "
88- DetailPrint " Removing stored credentials... "
64+ ReadRegStr $1 HKCU " Software\ AroCrypt" " Installed "
65+ StrCmp $1 " 1 " continueUninstall skipUninstall
8966
90- Call un.DeleteStoredCredential
91- ${EndIf}
67+ isUpdate:
68+ DetailPrint " Detected update mode. Only removing app files."
69+ DeleteRegValue HKCU " Software\AroCrypt" " Updating"
70+ RMDir /r " $INSTDIR"
71+ Goto endUninstall
72+
73+ skipUninstall:
74+ DetailPrint " Uninstall skipped: likely first-time install or unknown state."
75+ Goto endUninstall
76+
77+ continueUninstall:
78+ DetailPrint " Full uninstall detected."
79+
80+ DetailPrint " Removing file associations..."
81+ DeleteRegKey HKCR " .arocrypt"
82+ DeleteRegKey HKCR " AroCryptFile"
83+
84+ DetailPrint " Removing application files..."
85+ RMDir /r " $INSTDIR"
86+
87+ DetailPrint " Removing stored credentials..."
88+ Call un.DeleteStoredCredential
89+
90+ DeleteRegKey HKCU " Software\AroCrypt"
91+
92+ endUninstall:
93+ DetailPrint " Uninstall section complete."
9294
9395SectionEnd
9496
9597Function un.DeleteStoredCredential
9698 DetailPrint " Deleting stored credential 'AroCrypt/private_key'..."
9799 ExecWait ' cmd.exe /C "cmdkey /delete:AroCrypt/private_key"' $1
98- DetailPrint " Credential deletion command completed with exit code: $1"
99100 ${If} $1 == 0
100101 DetailPrint " Credential deleted successfully"
101102 ${Else}
0 commit comments