Skip to content
⌘ NSIS Forum Archive

Uninstall Password

6 posts

mustafakuk#

Uninstall Password

Hello, I just met nsis and it was able to do a few things successfully. However, I couldn't do the password request part while uninstalling the application. Can you help me?
mustafakuk#
!include nsDialogs.nsh
!include LogicLib.nsh
!include MUI2.nsh


Name "test Installer"
OutFile "test.exe"
RequestExecutionLevel admin
Unicode true
InstallDir c:\programdata\test
InstallDirRegKey HKLM "Software\test A.S." "Install_Dir"


; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES

Function SetRegistry

WriteRegStr HKLM "Software\Cekino Bilgi Teknolojileri A.S." "Install_Dir" "$INSTDIR"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\testA.S." "DisplayName" "Gardiyan Worker"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S." "DisplayVersion" "2.3.5"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\testA.S." "Publisher" "Cekino Bilgi Teknolojileri A.S."

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S." "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S." "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S." "NoRepair" 1
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S." "UninstallPassword" "123"
FunctionEnd

; The stuff to install
Section

SetOutPath $INSTDIR
File /r "C:\Users\test\Desktop\test\*.*"

Call SetRegistry
WriteUninstaller "$INSTDIR\uninstall.exe"

SimpleSC::InstallService "test" "test" "16" "2" "$INSTDIR\bin\test.exe" "" "" ""
SimpleSC::StartService "test" "" 30
SimpleSC::SetServiceDescription "test" "test service"
ExecWait 'schtasks /create /xml "$INSTDIR\WorkerUI.xml" /tn "WorkerUI"'
ExecWait 'schtasks /run /tn "WorkerUI"'
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\test A.S."
DeleteRegKey HKLM "Software\test A.S."

ExecWait 'schtasks /run /tn "WorkerUI"'
ExecWait 'schtasks /Delete /TN "WorkerUI"'

SimpleSC::StopService "test" 1 30
SimpleSC::RemoveService "test"

Delete $INSTDIR\*.*
Delete $INSTDIR\uninstall.exe
RMDir /r $INSTDIR

SectionEnd


This is the code, I want to write the uninstall password that I wrote here for the registry while doing the removal, if it is correct, I want it to be able to be removed. I have no idea how to do it.
Anders#
A custom page in the uninstaller that checks the password?

Also, is it not evil to require a password to uninstall?
mustafakuk#
The product we provide needs to be removed from clients, and our customers want it. There is nothing at the moment, I don't know how I can do this.
Anders#
Create a custom page in the uninstaller with a password field and compare with the result of ReadRegStr. Call abort in the leave callback if the passwords don't match.

You also need to take into account if the registry entry has been deleted for some reason, don't block uninstall in this case.