简单NSIS安装卸载脚本

装有安装与干净卸载作用

;Author: tinyms
;Date: 2011-06-22
;usage: replace NSIS/Contrib/zip2exe/Modern.nsh
;RequestExecutionLevel none|user|highest|admin

;RequestExecutionLevel user

!include "MUI.nsh"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "SimpChinese"

!define NAME "你的Exe名称"
;自行修改自己的安装包ico
Icon "D:/logo.ico"

Section
    SetOutPath $INSTDIR\\${NAME}\\bin
        ;修改自己Exe位置的快捷方式指向
    CreateShortCut $DESKTOP\\${NAME}.lnk $INSTDIR\\${NAME}\\bin\\${NAME}.exe
    SetShellVarContext All
        ;修改自己Exe位置的快捷方式指向
    CreateShortCut $SMPROGRAMS\\${NAME}.lnk $INSTDIR\\${NAME}\\bin\\${NAME}.exe
    WriteRegStr HKLM "Software\\${NAME}" "" "$INSTDIR"
        ;在控制面板中可以有删除项
    WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${NAME}" "DisplayName" "${NAME}"
    WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${NAME}" "UninstallString" '"$INSTDIR\\${NAME}\\uninst.exe"'
    WriteUninstaller "$INSTDIR\\${NAME}\\uninst.exe"
SectionEnd

Section "Uninstall"
    Delete $DESKTOP\\${NAME}.lnk
    SetShellVarContext All
    Delete $SMPROGRAMS\\${NAME}.lnk
    DeleteRegKey HKLM "Software\\${NAME}"
    DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${NAME}"
    RMDir /r "$INSTDIR"
SectionEnd
#该片段来自于http://outofmemory.cn
网站地图xml地图