NSIS脚本

!define ExeFile_NameStr "Doremisoft Webcam Studio" 

!define ExeUnit_NameStr "Doremisoft" 

!define PRODUCT_NAME "Webcam Studio" 

!define PRODUCT_VERSION "1.0.0" 

!define PRODUCT_WEB_SITE "http://www.doremisoft.net/webcam-studio/" 

!define InstallIndagateWeb "http://192.168.3.200:86/" 

!define ProduceIdStr "19" 

!define ProducteMode "Trial" 

!define TempOutPutIntallName "WebcamStudioTrial1.0.0" 

!define BrandName "WebcamStudio_C#" 

!define AutoComilatWorkPath "Z:\Install\" 

  

; Script generated by the HM NIS Edit Script Wizard.

BrandingText "${ExeUnit_NameStr} Inc."

; HM NIS Edit Wizard helper defines

!define PRODUCT_PUBLISHER "${ExeUnit_NameStr}, Inc."

!define PRODUCT_DIR_REGKEY "${ExeUnit_NameStr}\Microsoft\Windows\CurrentVersion\App Paths\${ExeFile_NameStr}.exe"

!define PRODUCT_UNINST_KEY "${ExeUnit_NameStr}\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"

!define PRODUCT_UNINST_ROOT_KEY "HKLM"

;

!define PRODUCT_SET "Software\${ExeUnit_NameStr}\${PRODUCT_NAME}\setting"

!define WorkPath "Z:\projects\tts\产品开发\code\uiworkspace\iOrgSoftDelphi\${BrandName}\product"

!define binPath "${AutoComilatWorkPath}\InstallFile"

; MUI 1.67 compatible ------

!include "MUI.nsh"

; MUI Settings

!define MUI_ABORTWARNING

!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"

!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"

!define MUI_WELCOMEFINISHPAGE_BITMAP "${AutoComilatWorkPath}\Install Image\PeonySoft-Win.bmp"

!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${AutoComilatWorkPath}\Install Image\PeonySoft-Win.bmp" 

/*  判断是不是.net4.0以上版本

Function .onInit

   call isStepFramework

   call isOnRun

   call IsUserAdmin

FunctionEnd

  Function isStepFramework

        ReadRegStr $0 HKLM SOFTWARE\Microsoft\.NETFramework\policy\v4.0 "30319"

        StrCmp $0 "30319-30319" 0 +2    

Return

MessageBox MB_OK|MB_ICONSTOP "To work with this software, you will need .NET Framework 4.0 or above.$\n If you don't have it on your PC,click OK to download it from official website."

ExecShell open "http://www.microsoft.com/download/en/details.aspx?id=24872"

abort

 FunctionEnd*/

 /* 判断是不是.net2.0以上版本 */

Function .onInit

   

   call isStepFramework

FunctionEnd

  Function isStepFramework

        ReadRegStr $0 HKLM SOFTWARE\Microsoft\.NETFramework\policy\v2.0 "50727"

        StrCmp $0 "50727-50727" 0 +2

Return

        ReadRegStr $0 HKLM SOFTWARE\Microsoft\.NETFramework\policy\v4.0 "30319"

        StrCmp $0 "30319-30319" 0 +2

Return

MessageBox MB_OK|MB_ICONSTOP "To work with this software, you will need .NET Framework 2.0 or above.$\n If you don't have it on your PC,click OK to download it from official website."

ExecShell open "http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en"

abort

 FunctionEnd

    

; GetWindowsVersion

 ;

 ; 基于 Yazno 的函数, http://yazno.tripod.com/powerpimpit/

 ; Joost Verburg 更新

 ;

 ; 返回到堆栈顶

 ;

 ; Windows 版本 (95, 98, ME, NT x.x, 2000, XP, 2003)

 ; 或

 ; '' (未知 Windows 版本)

 ;

 ; 用法:

 ;   Call GetWindowsVersion

 ;   Pop $R0

 ;   ; 在这里 $R0 is "NT 4.0" 或其它

 Function GetWindowsVersion

   Push $R0

   Push $R1

   ReadRegStr $R0 HKLM \

   "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

   IfErrors 0 lbl_winnt

   ; 不是 NT

   ReadRegStr $R0 HKLM \

   "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber

   StrCpy $R1 $R0 1

   StrCmp $R1 '4' 0 lbl_error

   StrCpy $R1 $R0 3

   StrCmp $R1 '4.0' lbl_win32_95

   StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98

   lbl_win32_95:

     StrCpy $R0 '95'

   Goto lbl_done

   lbl_win32_98:

     StrCpy $R0 '98'

   Goto lbl_done

   lbl_win32_ME:

     StrCpy $R0 'ME'

   Goto lbl_done

   lbl_winnt:

   StrCpy $R1 $R0 1

   StrCmp $R1 '3' lbl_winnt_x

   StrCmp $R1 '4' lbl_winnt_x

   StrCpy $R1 $R0 3

   StrCmp $R1 '5.0' lbl_winnt_2000

   StrCmp $R1 '5.1' lbl_winnt_XP

   StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error

   lbl_winnt_x:

     StrCpy $R0 "NT $R0" 6

   Goto lbl_done

   lbl_winnt_2000:

     Strcpy $R0 '2000'

   Goto lbl_done

   lbl_winnt_XP:

     Strcpy $R0 'XP'

   Goto lbl_done

   lbl_winnt_2003:

     Strcpy $R0 '2003'

   Goto lbl_done

   lbl_error:

     Strcpy $R0 ''

   lbl_done:

   Pop $R1

   Exch $R0

 FunctionEnd

/* 查找程序是否已经在运行 */

Function isOnRun

 FindProcDLL::FindProc "${ExeFile_NameStr}.exe"

    Pop $R0

    IntCmp $R0 1 run no_run

    run:

    MessageBox MB_OKCANCEL|MB_ICONINFORMATION "${PRODUCT_NAME} is running,please click OK to close the application program to finish the step,$\nand Cancel to exit from the steup of the program." IDOK true IDCANCEL false

    true:

        KillProcDLL::KillProc "${ExeFile_NameStr}.exe"

        Sleep 1000 

        return

    false:

       Quit   

    no_run:

FunctionEnd

Function IsUserAdmin

UserInfo::GetAccountType

Pop $R2

StrCmp $R2 "Admin" 0 Continue

  SetShellVarContext all

  Goto Done

  Continue:

  MessageBox MB_OK|MB_ICONINFORMATION "Install the program under administrator account."

  Quit

  Done:

FunctionEnd

; Welcome page

!insertmacro MUI_PAGE_WELCOME

; License page

!define MUI_LICENSEPAGE_RADIOBUTTONS

!insertmacro MUI_PAGE_LICENSE "${WorkPath}\Source\ElseFile\Doc\${ExeUnit_NameStr}.txt"

; Directory page

!insertmacro MUI_PAGE_DIRECTORY

; Instfiles page

!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_RUN "$INSTDIR\${ExeFile_NameStr}.exe"

;Cancel Unenable

Function OnPreFinish

  !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "CancelEnabled" "0"

FunctionEnd 

!define MUI_PAGE_CUSTOMFUNCTION_PRE "OnPreFinish"

!insertmacro MUI_PAGE_FINISH

; Uninstaller pages

!insertmacro MUI_UNPAGE_INSTFILES

; Language files

!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${ProducteMode} ${PRODUCT_VERSION} "

OutFile "${TempOutPutIntallName}.exe"

InstallDir "$PROGRAMFILES\${ExeUnit_NameStr}\${PRODUCT_NAME}"

InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""

ShowInstDetails show

ShowUnInstDetails show

RequestExecutionLevel user

Section "MainSection" SEC01

  SetShellVarContext all

  SetOutPath "$INSTDIR"

  SetOverwrite on

File /r "${binPath}\*.*" 

SetOutPath "$INSTDIR"

  SetShellVarContext all

  CreateDirectory "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}"

  CreateShortCut "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${ExeFile_NameStr}.exe"

  CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${ExeFile_NameStr}.exe"

SectionEnd

Section -AdditionalIcons

  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"

  ;CreateShortCut "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"

  CreateShortCut "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"

SectionEnd

Section -Post

  WriteUninstaller "$INSTDIR\uninst.exe"

  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\\${ExeFile_NameStr}.exe"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${ExeFile_NameStr}.exe"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"

SectionEnd

Function un.onUninstSuccess

  HideWindow

  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) Uninstall successfully!"

FunctionEnd

Function un.onInit

  call un.ISonInit

  call un.IsUserAdmin

  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure remove $(^Name)?" IDYES +2

  Abort

FunctionEnd

Function un.ISonInit

 FindProcDLL::FindProc "${ExeFile_NameStr}.exe"

    Pop $R0

    IntCmp $R0 1 0 no_run

    MessageBox MB_OKCANCEL|MB_ICONINFORMATION "${PRODUCT_NAME} is running,please click OK to close the application program $\n to finish the uninstall,and Cancel to exit from the uninstall of the program." IDOK true IDCANCEL false

    true:

        KillProcDLL::KillProc "${ExeFile_NameStr}.exe"

        Sleep 1000 

        return

    false:

       Quit   

    no_run:

 FunctionEnd

Function un.IsUserAdmin

UserInfo::GetAccountType

Pop $R2

StrCmp $R2 "Admin" 0 Continue

  SetShellVarContext all

  Goto Done

  Continue:

  MessageBox MB_OK|MB_ICONINFORMATION "Unistall the program under administrator account."

  Quit

  Done:

FunctionEnd

Section Install

  WriteRegStr HKCU "${PRODUCT_SET}" "InstallName" "$CMDLINE"

SectionEnd

Section Install

  SetShellVarContext all

  WriteRegStr HKCU "${PRODUCT_SET}" "InstallName" "$CMDLINE"

  WriteRegStr HKLM "SOFTWARE\Doremi\Video Capture" "Main Application" "$INSTDIR\${ExeFile_NameStr}.exe"

  RegDLL  "$INSTDIR\vcam.dll"

   Call GetWindowsVersion

   Pop $R0

   ; MessageBox MB_OK "$R0"

   StrCmp $0 "xp" 0

    ExecWait '"$INSTDIR\ChangeDll.exe"'

    

SectionEnd

/******************************

 *  以下是安装程序的卸载部分  *

 ******************************/

Section Uninstall

  SetShellVarContext all

  Delete "$INSTDIR\${PRODUCT_NAME}.url"

  UnRegDLL "$INSTDIR\vcam.dll"

 /* Delete "$INSTDIR\uninst.exe"

  Delete "$INSTDIR\${ExeFile_NameStr}.exe"

  Delete "$INSTDIR\*.dll"

  ;Delete "$INSTDIR\Help-video.chm"

  Delete "$INSTDIR\watermark.jpg"

  Delete "$INSTDIR\watermark.dat"

  Delete "$INSTDIR\*.xml"

  Delete "$INSTDIR\*.dat"

  Delete "$INSTDIR\*.bmp"

  Delete "$INSTDIR\*.exe"

;rmdll

  RMDir /r  "$INSTDIR\rmdll"   

;Images

  RMDir /r "$INSTDIR\Skins"

;profile

  RMDir /r "$INSTDIR\profile"

;language

  RMDir /r "$INSTDIR\lang"

;update

  RMDir /r "$INSTDIR\Update"

  */

  

;lnk

  Delete "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\Uninstall.lnk"

 ; Delete "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\Website.lnk"

  Delete "$DESKTOP\${PRODUCT_NAME}.lnk"

  Delete "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"

  RMDir /r "$SMPROGRAMS\${ExeUnit_NameStr}\${PRODUCT_NAME}"

  

  RMDir /r "$INSTDIR"

   

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"

  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"

  DeleteRegKey HKCU "${PRODUCT_SET}"

  DeleteRegKey HKLM "SOFTWARE\Doremi\Video Capture"

  SetAutoClose true

SectionEnd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值