NSIS (Nullsoft Scriptable Install System)是一个开源的 Windows 系统下安装程序制作程序,它通过脚本语言来描述安装程序的行为和逻辑。

项目主页:http://nsis.sourceforge.net/
 
下面是一个基本的安装程序脚本模板(建议使用HM NIS Edit来编辑,编译):
!include "Library.nsh"

!define PRODUCT_NAME "XXX系统"
!define PRODUCT_VERSION "1.2.1"
!define PRODUCT_PUBLISHER "XX电子科技"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\YYYY.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

!include "MUI.nsh"

!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"

!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "SimpChinese"

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup\YYYY_Setup_${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\YYYY"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  File "Bin\ef_simulate_client.py"
  File "Bin\ef_simulate_server.py"
  File "Bin\ef_display_client.py"
  File "Bin\YYYY.exe"
  File "Bin\YYYY.exe.config"
  File "Bin\SQLite.Interop.dll"
  
  SetOutPath "$INSTDIR\Audios"
  File /r "Bin\Audios\*.*"
  
  SetOutPath "$INSTDIR\Data"
  File /r "Bin\Data\*.*"
  
  SetOutPath "$INSTDIR\Icons"
  File /r "Bin\Icons\*.*"
  
  SetOutPath "$INSTDIR\Images"
  File /r "Bin\Images\*.*"
  
  CreateDirectory "$INSTDIR\Log"
  
  !insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "Bin\zkemkeeper.dll" $INSTDIR\abcd.dll $INSTDIR
  
  SetShellVarContext all
  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}${PRODUCT_VERSION}"
  CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}${PRODUCT_VERSION}\${PRODUCT_NAME}${PRODUCT_VERSION}.lnk" "$INSTDIR\YYYY.exe"
  CreateShortCut     "$DESKTOP\${PRODUCT_NAME}${PRODUCT_VERSION}.lnk" "$INSTDIR\YYYY.exe"
SectionEnd

Section -AdditionalIcons
  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}${PRODUCT_VERSION}\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\YYYY.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\YYYY.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"
FunctionEnd

Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ,其及所有的组件?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  !insertmacro UninstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $INSTDIR\zkemkeeper.dll

  SetShellVarContext current
  Delete "$DESKTOP\${PRODUCT_NAME}${PRODUCT_VERSION}.lnk"
  RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}${PRODUCT_VERSION}"
  
  SetShellVarContext all
  Delete "$DESKTOP\${PRODUCT_NAME}${PRODUCT_VERSION}.lnk"
  RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}${PRODUCT_VERSION}"
  
  RMDir /r "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  SetAutoClose true
SectionEnd

本文链接地址: NSIS 安装程序脚本模板
http://qingfengju.com/index.asp?id=378

分类:脚本编程 查看次数:11243 发布时间:2014/10/31 20:12:25

// 在浏览器中设置:
// file://D:/Desktop/test.pac
function FindProxyForURL(url,host)
{
    // 在家
    if(shExpMatch(myIpAddress(),"192.168.1.*"))
    {
        return "direct";
    }
    else
    {
        // 在办公室
        if(shExpMatch(host,"172.16.*") ||
           shExpMatch(host,"*cmsz*"))
        {
            return "direct";
        }
        else if( shExpMatch(host,"*sina*") ||
                 shExpMatch(host,"*163*") )
        {
            return "proxy 61.50.■■■■■:■■■■■";
        }
        else
        {
            return "proxy 192.168.■■■■■:■■■■■";
        }
    }
}

 
参考:
http://www.cnblogs.com/ttyp/archive/2005/11/18/279124.html 《自动配置IE代理脚本》
http://technet.microsoft.com/en-us/library/dd361950.aspx 《JavaScript or JScript Auto-Proxy Example Files》
http://support.microsoft.com/kb/271361 《如何在 Internet Explorer 中禁用自动代理缓存》
http://support.microsoft.com/kb/274204 《.Pac 文件中的 shExpMatch 函数不支持正则表达式》


本文链接地址: 浏览器的自动代理脚本示例
http://qingfengju.com/index.asp?id=377

分类:脚本编程 查看次数:6659 发布时间:2014/9/11 17:25:14