复制代码 代码如下:
;我的第一个安装脚本
!include "MUI2.nsh"
!define DIR "D:workspacensisfiles"
Name "安装程序"
Icon "${DIR}setup128.ico"
OutFile "setup.exe"
InstallDir "$PROGRAMFILESkaserv"
RequestExecutionLevel admin
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "SimpChinese"
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0,i 0,t "SMAPLE_MUTEX") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONSTOP "只允许运行一个实例"
Abort
FunctionEnd
;安装程序段
Section
SetOutPath $INSTDIR
File "${DIR}新建文本文档 (2).txt"
File "${DIR}新建文本文档.txt"
SetOutPath "$INSTDIRoffice"
File "${DIR}office*"
;快捷方式
CreateShortCut "$DESKTOPtest.lnk" "$INSTDIRunsetup.exe"
CreateShortCut "$SMPROGRAMStest.lnk" "$INSTDIRunsetup.exe"
WriteUninstaller "$INSTDIRunsetup.exe"
SectionEnd
;卸载程序段
Section "Uninstall"
RMDir /r "$INSTDIR"
Delete "$DESKTOPtest.lnk"
Delete "$SMPROGRAMStest.lnk"
SectionEnd