NSIS自动检测
优质
小牛编辑
149浏览
2023-12-01
脚本例子一:
!include "MUI.nsh" OutFile "S32.exe" !define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentsPage1Pre !insertmacro MUI_PAGE_COMPONENTS Sectiongroup "完整独立程序" SecOL3 Section /o "QQ直播程序" Sec60 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQLive5.0.3240.exe" ExecWait '"$TEMP\QQLive5.0.3240.exe /S' SectionEnd Section /o "QQ音乐程序" Sec20 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQMusicClickInstall.exe" ExecWait '"$TEMP\QQMusicClickInstall.exe /S' SectionEnd Section /o "QQ医生程序" Sec30 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "qqdoctor1.3kb1setup.exe" ExecWait '"$TEMP\qqdoctor1.3kb1setup.exe /S' SectionEnd Section /o "QQ旋风程序" Sec50 SectionIn 1 SetOutPath "$TEMP" setoverwrite on File "qqdownload1.4b1.exe" ExecWait '"$TEMP\qqdownload1.4b1.exe /S' SectionEnd Section /o "QQ游戏程序" Sec40 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQGame2007Beta1_setup.EXE" ExecWait '"$TEMP\QQGame2007Beta1_setup.EXE /S' SectionEnd SectionGroupend Function ComponentsPage1Pre Call Check1 Call Check2 Call Check3 Call Check4 Call Check5 FunctionEnd Function Check1 IfFileExists $PROGRAMFILES\NSIS\NSIS.exe skip !insertmacro UnselectSection ${Sec60} skip: FunctionEnd Function Check2 IfFileExists $PROGRAMFILESA\A.exe skip !insertmacro UnselectSection ${Sec20} skip: FunctionEnd Function Check3 IfFileExists $PROGRAMFILES\DAEMON Tools\DAEMON.exe skip !insertmacro UnselectSection ${Sec30} skip: FunctionEnd Function Check4 IfFileExists $PROGRAMFILES\QQGAME\Game.exe skip !insertmacro UnselectSection ${Sec40} skip: FunctionEnd Function Check5 IfFileExists $windir\notepad skip !insertmacro UnselectSection ${Sec50} skip: FunctionEnd
脚本例子二:
!include Sections.nsh Name TestSelectSection OutFile "TestSelectSection.exe" Page components Page instfiles ShowInstDetails show Sectiongroup "完整独立程序" SecOL3 Section /o "QQ直播程序" Sec60 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQLive5.0.3240.exe" ExecWait '"$TEMP\QQLive5.0.3240.exe /S' SectionEnd Section /o "QQ音乐程序" Sec20 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQMusicClickInstall.exe" ExecWait '"$TEMP\QQMusicClickInstall.exe /S' SectionEnd Section /o "QQ医生程序" Sec30 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "qqdoctor1.3kb1setup.exe" ExecWait '"$TEMP\qqdoctor1.3kb1setup.exe /S' SectionEnd Section /o "QQ旋风程序" Sec50 SectionIn 1 SetOutPath "$TEMP" setoverwrite on File "qqdownload1.4b1.exe" ExecWait '"$TEMP\qqdownload1.4b1.exe /S' SectionEnd Section /o "QQ游戏程序" Sec40 SectionIn 1 2 SetOutPath "$TEMP" setoverwrite on File "QQGame2007Beta1_setup.EXE" ExecWait '"$TEMP\QQGame2007Beta1_setup.EXE /S' SectionEnd SectionGroupend IfFileExists $windir\notepad.exe QQliveExists PastQQliveCheck QQliveExists: !insertmacro SelectSection ${SEC60} PastQQliveCheck: ;/////////////////////QQ音乐////////////////////////////////////////////////// IfFileExists $windir\notepad.exe QQmusicExists PastQQmusicCheck QQmusicExists: !insertmacro SelectSection ${SEC20} PastQQmusicCheck: ;/////////////////////QQ医生////////////////////////////////////////////////// IfFileExists $windir\notepad.exe QQdoctorExists PastQQdoctorCheck QQdoctorExists: !insertmacro SelectSection ${SEC30} PastQQdoctorCheck: ;/////////////////////QQ旋风////////////////////////////////////////////////// IfFileExists $windir\notepad.exe QQdownloadExists PastQQdownloadCheck QQdownloadExists: !insertmacro SelectSection ${SEC40} PastQQdownloadCheck: ;//////////////////////QQ游戏///////////////////////////////////////////////// IfFileExists $windir\notepad.exe QQgameExists PastQQgameCheck QQgameExists: !insertmacro SelectSection ${SEC50} PastQQgameCheck: FunctionEnd !include Sections.nsh Section "Photoshop plug-ins" ps_plugins SectionEnd Function .onInit IfFileExsists $PROGRAMFILES\Photoshop\main.exe psins !insertmacro SelectSection ${ps_plugins} Goto done psins: !insertmacro UnselectSection ${ps_plugins} done: FunctionEnd