/admin/win/nsi/nsis_uac/UAC_Uninstaller.nsi

http://github.com/tomahawk-player/tomahawk · Unknown · 49 lines · 42 code · 7 blank · 0 comment · 0 complexity · 942d3ac519e77d75dc5f2f068a2a2379 MD5 · raw file

  1. /*
  2. This script was made in response to http://forums.winamp.com/showthread.php?threadid=280330
  3. It is a ugly hack and is mostly here just to have a solution right now.
  4. Hopefully, NSIS will add support for changing the RequestExecutionLevel of the uninstaller
  5. This code inspired the _UAC.GenerateUninstallerTango macro (called by ${UAC.U.Elevate.AdminOnly} unless you define UAC_DISABLEUNINSTALLERTANGO)
  6. */
  7. RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
  8. !define APPNAME "UAC_Uninstaller"
  9. Name "${APPNAME}"
  10. OutFile "${APPNAME}.exe"
  11. ShowInstDetails show
  12. !include LogicLib.nsh
  13. !define UNINSTALLER_UACDATA "uac.ini"
  14. !define UNINSTALLER_NAME "Uninstall FooBarBaz"
  15. Function un.onInit
  16. ReadIniStr $0 "$ExeDir\${UNINSTALLER_UACDATA}" UAC "Un.First"
  17. ${IF} $0 != 1
  18. ;SetSilent silent
  19. InitPluginsDir
  20. WriteIniStr "$PluginsDir\${UNINSTALLER_UACDATA}" UAC "Un.First" 1
  21. CopyFiles /SILENT "$EXEPATH" "$PluginsDir\${UNINSTALLER_NAME}.exe"
  22. StrCpy $0 ""
  23. ${IfThen} ${Silent} ${|} StrCpy $0 "/S " ${|}
  24. ExecWait '"$PluginsDir\${UNINSTALLER_NAME}.exe" $0/NCRC _?=$INSTDIR' $0
  25. SetErrorLevel $0
  26. Quit
  27. ${EndIf}
  28. # UAC code goes here ...
  29. FunctionEnd
  30. Section
  31. WriteUninstaller "$exedir\${UNINSTALLER_NAME}.exe"
  32. SetAutoClose true
  33. DetailPrint "Uninstalling..."
  34. Sleep 1111
  35. Exec '"$exedir\${UNINSTALLER_NAME}.exe"'
  36. SectionEnd
  37. Section uninstall
  38. MessageBox mb_ok "My filename is: $EXEFILE"
  39. Delete "$instdir\${UNINSTALLER_NAME}.exe"
  40. Delete "$instdir\${APPNAME}.exe" ;delete generated installer aswell, this is just a sample script
  41. SectionEnd
  42. page InstFiles