最新消息:

在网上下载配置文件并运行相应程序

nsis 永恒心锁 1644浏览 0评论
OutFile "RandomPage.EXE"
Name "RandomPage"
!include "MUI2.nsh"
SetFont "tahoma" 8
Var NoNetwork
Var ID1
Var ID2
Var ID3
Var ID4
Var Dialog
Var Checkbox1
Var Checkbox2
Var Checkbox3
Var Checkbox4
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
Page custom RandomPageShow RandomPageLeave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "SimpChinese"
Section
SectionEnd
Function .onInit
;下载服务器的INI,否则记住,不显示此页。
InitPluginsDir
inetc::get /SILENT "http://127.0.0.1/RandomPage.ini" "$PLUGINSDIRRandomPage.ini"
Pop $0
StrCmp $0 "OK" +2 ;下载ini文件不成功视为无网络
StrCpy $NoNetwork 1 ;无网络标志
;获取时间
System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r0'
System::Call 'kernel32::GetLocalTime(i)i(r0)'
;时间除7求余数得ID1
IntOp $ID1 $0 % 7
;ID1加一再除7求余数
IntOp $ID2 $ID1 + 1
IntOp $ID2 $ID2 % 7
;ID2加一再除7求余数
IntOp $ID3 $ID2 + 1
IntOp $ID3 $ID3 % 7
;ID3加一再除7求余数
IntOp $ID4 $ID3 + 1
IntOp $ID4 $ID4 % 7
;得出0~6的连续不同数.
FunctionEnd
Function RandomPageShow
StrCmp $NoNetwork 1 NoNeedPage ;如果没有网络,不需要显示.
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${NSD_CreateLabel} 0 0u 100% 25u "感谢安装超级兔子,欢迎安装下列为你推荐的附加组件。"
;做四个checkbox,标题和是否默认选择由INI决定
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Title" $ID1
${NSD_CreateCheckbox} 0 30u 100% 10u "$R1"
Pop $Checkbox1
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "IsCheckDefault" $ID1
${NSD_SetState} $Checkbox1 $R1
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Title" $ID2
${NSD_CreateCheckbox} 0 45u 100% 10u "$R1"
Pop $Checkbox2
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "IsCheckDefault" $ID2
${NSD_SetState} $Checkbox2 $R1
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Title" $ID3
${NSD_CreateCheckbox} 0 60u 100% 10u "$R1"
Pop $Checkbox3
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "IsCheckDefault" $ID3
${NSD_SetState} $Checkbox3 $R1
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Title" $ID4
${NSD_CreateCheckbox} 0 75u 100% 10u "$R1"
Pop $Checkbox4
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "IsCheckDefault" $ID4
${NSD_SetState} $Checkbox4 $R1
nsDialogs::Show
NoNeedPage:
FunctionEnd
Function RandomPageLeave
StrCmp $NoNetwork 1 NoNeedLeavePage ;如果没有网络,不需要显示.
Push $R0
Push $R1
Push $R2
${NSD_GetState} $Checkbox1 $R0
StrCmp $R0 1 +1 NOCheck1 ;检查Checkbox有没选择
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "URL" $ID1 ;读URL
StrCmp $R1 "" +2 ;没有跳过打开网址
ExecShell open "$R1" SW_SHOWNORMAL
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Execute" $ID1 ;读需要下载执行的文件网址
StrCmp $R1 "" NOCheck1 ;没有跳过下载打开程序
inetc::get /SILENT "$R1" "$PLUGINSDIR1.exe" ;下载程序为"$PLUGINSDIR1.exe"
Pop $R0
StrCmp $R0 "OK" +1 NOCheck1 ;下载成功开始运行,运行是否ExecWait由INI决定.
ReadINIStr $R2 "$PLUGINSDIRRandomPage.ini" "ExecWait" $ID1
StrCmp $R2 1 +1 +3
ExecWait "$PLUGINSDIR1.exe"
Goto +2
Exec "$PLUGINSDIR1.exe"
NOCheck1:
${NSD_GetState} $Checkbox2 $R0
StrCmp $R0 1 +1 NOCheck2
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "URL" $ID2
StrCmp $R1 "" +2
ExecShell open "$R1" SW_SHOWNORMAL
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Execute" $ID2
StrCmp $R1 "" NOCheck2
inetc::get /SILENT "$R1" "$PLUGINSDIR2.exe"
Pop $R0
StrCmp $R0 "OK" +1 NOCheck2
ReadINIStr $R2 "$PLUGINSDIRRandomPage.ini" "ExecWait" $ID2
StrCmp $R2 1 +1 +3
ExecWait "$PLUGINSDIR2.exe"
Goto +2
Exec "$PLUGINSDIR2.exe"
NOCheck2:
${NSD_GetState} $Checkbox3 $R0
StrCmp $R0 1 +1 NOCheck3
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "URL" $ID3
StrCmp $R1 "" +2
ExecShell open "$R1" SW_SHOWNORMAL
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Execute" $ID3
StrCmp $R1 "" NOCheck3
inetc::get /SILENT "$R1" "$PLUGINSDIR3.exe"
Pop $R0
StrCmp $R0 "OK" +1 NOCheck3
ReadINIStr $R2 "$PLUGINSDIRRandomPage.ini" "ExecWait" $ID3
StrCmp $R2 1 +1 +3
ExecWait "$PLUGINSDIR3.exe"
Goto +2
Exec "$PLUGINSDIR3.exe"
NOCheck3:
${NSD_GetState} $Checkbox4 $R0
StrCmp $R0 1 +1 NOCheck4
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "URL" $ID4
StrCmp $R1 "" +2
ExecShell open "$R1" SW_SHOWNORMAL
ReadINIStr $R1 "$PLUGINSDIRRandomPage.ini" "Execute" $ID4
StrCmp $R1 "" NOCheck4
inetc::get /SILENT "$R1" "$PLUGINSDIR4.exe"
Pop $R0
StrCmp $R0 "OK" +1 NOCheck4
ReadINIStr $R2 "$PLUGINSDIRRandomPage.ini" "ExecWait" $ID4
StrCmp $R2 1 +1 +3
ExecWait "$PLUGINSDIR4.exe"
Goto +2
Exec "$PLUGINSDIR4.exe"
NOCheck4:
Pop $R2
Pop $R1
Pop $R0
NoNeedLeavePage:
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 在网上下载配置文件并运行相应程序

您必须 登录 才能发表评论!