NSIS在网上下载配置文件并运行相应程序,nsis,服务器配置文件,远程下载配置文件
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
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" "$PLUGINSDIR\RandomPage.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 "$PLUGINSDIR\RandomPage.ini" "Title" $ID1 ${NSD_CreateCheckbox} 0 30u 100% 10u "$R1" Pop $Checkbox1 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "IsCheckDefault" $ID1 ${NSD_SetState} $Checkbox1 $R1 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Title" $ID2 ${NSD_CreateCheckbox} 0 45u 100% 10u "$R1" Pop $Checkbox2 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "IsCheckDefault" $ID2 ${NSD_SetState} $Checkbox2 $R1 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Title" $ID3 ${NSD_CreateCheckbox} 0 60u 100% 10u "$R1" Pop $Checkbox3 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "IsCheckDefault" $ID3 ${NSD_SetState} $Checkbox3 $R1 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Title" $ID4 ${NSD_CreateCheckbox} 0 75u 100% 10u "$R1" Pop $Checkbox4 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.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 "$PLUGINSDIR\RandomPage.ini" "URL" $ID1 ;读URL StrCmp $R1 "" +2 ;没有跳过打开网址 ExecShell open "$R1" SW_SHOWNORMAL ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Execute" $ID1 ;读需要下载执行的文件网址 StrCmp $R1 "" NOCheck1 ;没有跳过下载打开程序 inetc::get /SILENT "$R1" "$PLUGINSDIR\1.exe" ;下载程序为"$PLUGINSDIR\1.exe" Pop $R0 StrCmp $R0 "OK" +1 NOCheck1 ;下载成功开始运行,运行是否ExecWait由INI决定. ReadINIStr $R2 "$PLUGINSDIR\RandomPage.ini" "ExecWait" $ID1 StrCmp $R2 1 +1 +3 ExecWait "$PLUGINSDIR\1.exe" Goto +2 Exec "$PLUGINSDIR\1.exe" NOCheck1: ${NSD_GetState} $Checkbox2 $R0 StrCmp $R0 1 +1 NOCheck2 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "URL" $ID2 StrCmp $R1 "" +2 ExecShell open "$R1" SW_SHOWNORMAL ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Execute" $ID2 StrCmp $R1 "" NOCheck2 inetc::get /SILENT "$R1" "$PLUGINSDIR\2.exe" Pop $R0 StrCmp $R0 "OK" +1 NOCheck2 ReadINIStr $R2 "$PLUGINSDIR\RandomPage.ini" "ExecWait" $ID2 StrCmp $R2 1 +1 +3 ExecWait "$PLUGINSDIR\2.exe" Goto +2 Exec "$PLUGINSDIR\2.exe" NOCheck2: ${NSD_GetState} $Checkbox3 $R0 StrCmp $R0 1 +1 NOCheck3 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "URL" $ID3 StrCmp $R1 "" +2 ExecShell open "$R1" SW_SHOWNORMAL ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Execute" $ID3 StrCmp $R1 "" NOCheck3 inetc::get /SILENT "$R1" "$PLUGINSDIR\3.exe" Pop $R0 StrCmp $R0 "OK" +1 NOCheck3 ReadINIStr $R2 "$PLUGINSDIR\RandomPage.ini" "ExecWait" $ID3 StrCmp $R2 1 +1 +3 ExecWait "$PLUGINSDIR\3.exe" Goto +2 Exec "$PLUGINSDIR\3.exe" NOCheck3: ${NSD_GetState} $Checkbox4 $R0 StrCmp $R0 1 +1 NOCheck4 ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "URL" $ID4 StrCmp $R1 "" +2 ExecShell open "$R1" SW_SHOWNORMAL ReadINIStr $R1 "$PLUGINSDIR\RandomPage.ini" "Execute" $ID4 StrCmp $R1 "" NOCheck4 inetc::get /SILENT "$R1" "$PLUGINSDIR\4.exe" Pop $R0 StrCmp $R0 "OK" +1 NOCheck4 ReadINIStr $R2 "$PLUGINSDIR\RandomPage.ini" "ExecWait" $ID4 StrCmp $R2 1 +1 +3 ExecWait "$PLUGINSDIR\4.exe" Goto +2 Exec "$PLUGINSDIR\4.exe" NOCheck4: Pop $R2 Pop $R1 Pop $R0 NoNeedLeavePage: FunctionEnd |
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=1254