最新消息:

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

nsis 永恒心锁 2067浏览 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
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

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

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址