Uninstall Renamed-Moved-Copied Shortcuts: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 124: | Line 124: | ||
[[Category:Code Examples]] | [[Category:Code Examples]] | ||
[[Category:Real World Installers]] |
Revision as of 17:49, 3 January 2007
Author: Red Wine (talk, contrib) |
Description
The research on the subject uninstall shrotcuts that have been possible renamed and/or moved copied started on this forum thread.
Requires RecFind.nsh by Afrow UK and ShellLink plug-in.
The Code
Name "My App" OutFile "MyApp.exe" InstallDir '$PROGRAMFILES\My App' InstallDirRegKey HKCU "Software\My App" "" ShowInstDetails show ShowUninstDetails show !include 'RecFind.nsh' !define ICON_SEARCH '$SMPROGRAMS$R0\$R1' !define DESK_SEARCH '$DESKTOP$R0\$R1' !define MyApp '$INSTDIR\makensisw.exe' !define Uninst '$INSTDIR\uninstall.exe' var SM_FOLDER page directory page instfiles Section Install SetOutPath '$INSTDIR' File '${NSISDIR}\makensisw.exe' createshortcut '$DESKTOP\makensisw.lnk' '${MyApp}' createdirectory '$SMPROGRAMS\My App' createshortcut '$SMPROGRAMS\My App\makensisw.lnk' '${myApp}' writeuninstaller '${Uninst}' createshortcut '$SMPROGRAMS\My App\uninstall.lnk' '${Uninst}' WriteRegStr HKCU "Software\My App" "" "$INSTDIR" sectionend # In order to examine the example uncomment the following section. # By doing this, shortcuts will be renamed and copied to All Users as well. # Of course you may manoually rename move copy the shortcuts the way you like. /* Section RenameCreatedShortCuts Rename '$SMPROGRAMS\My App' '$SMPROGRAMS\My Renamed App' Rename '$SMPROGRAMS\My Renamed App\makensisw.lnk' \ '$SMPROGRAMS\My Renamed App\Renamed makensisw.lnk' Rename '$SMPROGRAMS\My Renamed App\uninstall.lnk' \ '$SMPROGRAMS\My Renamed App\Renamed uninstall.lnk' CopyFiles '$DESKTOP\makensisw.lnk' '$DESKTOP\copied makensisw.lnk' StrCpy '$R9' '$SMPROGRAMS' StrCpy '$R8' '$DESKTOP' SetShellVarContext all CreateDirectory '$SMPROGRAMS\My ALL USERS App' CopyFiles '$R9\My Renamed App\*' '$SMPROGRAMS\My ALL USERS App' CopyFIles '$R8\makensisw.lnk' '$DESKTOP\ALL USERS makensisw.lnk' CopyFIles '$R8\copied makensisw.lnk' '$DESKTOP\copied ALL USERS makensisw.lnk' SectionEnd */ Section Uninstall Delete ${MyApp} Delete ${Uninst} RmDir '$INSTDIR' Call un.StartMenuClean Call un.DesktopClean DeleteRegKey HKCU "Software\My App" SectionEnd Function un.StartMenuClean StrCpy '$R9' '0' start: ${RecFindOpen} '$SMPROGRAMS' '$R0' '$R1' ${RecFindFirst} ; DetailPrint '${ICON_SEARCH}' ShellLink::GetShortCutTarget '${ICON_SEARCH}' Pop $0 StrCmp '$0' '${MyApp}' 0 next MessageBox mb_ok '${ICON_SEARCH}' StrCpy '$SM_FOLDER' '$R0' Delete '${ICON_SEARCH}' next: StrCmp '$0' '${Uninst}' 0 end MessageBox mb_ok '${ICON_SEARCH}' Delete '${ICON_SEARCH}' end: ${RecFindNext} ${RecFindClose} StrCmp '$SM_FOLDER' '' +3 MessageBox mb_ok '$SMPROGRAMS$SM_FOLDER' RmDir '$SMPROGRAMS$SM_FOLDER' StrCmp '$R9' '1' func_end SetShellVarContext all StrCpy '$SM_FOLDER' '' StrCpy '$R9' '1' goto start func_end: FunctionEnd Function un.DesktopClean StrCpy '$R9' '0' start: ${RecFindOpen} '$DESKTOP' '$R0' '$R1' ${RecFindFirst} ; DetailPrint '${DESK_SEARCH}' ShellLink::GetShortCutTarget '${DESK_SEARCH}' Pop $0 StrCmp '$0' '${MyApp}' 0 next messagebox mb_ok '${DESK_SEARCH}' Delete '${DESK_SEARCH}' next: ${RecFindNext} ${RecFindClose} StrCmp '$R9' '1' func_end SetShellVarContext current StrCpy '$R9' '1' goto start func_end: FunctionEnd