先在dependicies中新建目录dotnet2_0/并放入dotnetfx.exe;dependicies目录中再加xml 代码如下
1 <DependencyTemplate> 2 3 <Dependency> 4 5 <Name>Microsoft .NET Framework 2.0</Name> 6 7 <RuntimeTempFolder>dotnet2_0</RuntimeTempFolder> 8 9 <RevisionDate>Friday, March 30, 2007</RevisionDate> 10 11 <Description>安装 Microsoft .NET Framework 2.0应用程序所需的运行时文件。</Description> 12 13 <DetectScript> 14 15 function isDotNet_Installed() 16 17 --author:zhengxinhe www.admans.net 18 19 -- Output to the log that the .NET detection has started. 20 21 SetupData.WriteToLogFile("Success\t.NET 2.0 Module: Detection script started.\r\n", true); 22 23 -- Get the operating system name. 24 25 --Check to see if the registry key exists 26 27 DotNet_Registry = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\.NETFramework"); 28 29 if (DotNet_Registry == nil) then 30 31 -- The registry key does not exist 32 33 -- Run the .NET Installation script 34 35 -- Output to the log file that .NET could not be found, so it will be installed. 36 37 SetupData.WriteToLogFile("Info\t.NET 2.0 Module: No version of .NET 2.0 files was found. .NET 2.0 will be installed.\r\n", true); 38 39 return false; 40 41 end 42 43 -- The key does exist 44 45 -- Get the .NET install location from the registry 46 47 DotNet_Install_Location = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\.NETFramework", "InstallRoot", true); 48 49 -- Look for the file mscorcfg.dll 50 51 Does_File_Exist = DotNet_Install_Location.."\\v2.0.50727\\aspnet_rc.dll"; 52 53 if(not File.DoesExist(Does_File_Exist))then 54 55 -- The file does not exist 56 57 -- Run the .NET Installation script 58 59 -- Output to the log file that .NET could not be found, so it will be installed. 60 61 SetupData.WriteToLogFile("Info\t.NET 2.0 Module: No version of .NET 2.0 file was found. .NET 2.0 will be installed.\r\n", true); 62 63 return false; 64 65 end 66 67 -- The file does exist 68 69 -- Get the version of mscorcfg.dll 70 71 msc_ver = File.GetVersionInfo(Does_File_Exist); 72 73 if(not msc_ver)then 74 75 SetupData.WriteToLogFile("Info\t.NET 2.0 Module: no version was found. .NET 2.0 will be installed.\r\n", true); 76 77 return false; 78 79 end 80 81 82 83 -- Compare the returned value against the needed value 84 85 Compare = String.CompareFileVersions(msc_ver.FileVersion, "2.0.50727.42"); 86 87 if (Compare == -1) then 88 89 -- Output to the log file that a lesser version of .NET was found on the system 90 91 SetupData.WriteToLogFile("Info\t.NET 2.0 Module: A lesser version of .NET 2.0("..msc_ver.FileVersion..") was found on the users system.\r\n", true); 92 93 return false; 94 95 else 96 97 -- a version less than version 2.0 is installed 98 99 -- Output to the log file that a lesser version of .NET was found on the system 100 101 SetupData.WriteToLogFile("Info\t.NET 2.0 Module: A new or this version of .NET 2.0 was found on the users system.\r\n", true); 102 103 return true; 104 105 end 106 107 end 108 109 </DetectScript> 110 111 <DetectFunction>isDotNet_Installed</DetectFunction> 112 113 <InstallScript> 114 115 -- 用在安装操作中的变量: 116 117 local strMessage = [[安装程序检测到你的系统没有安装Microsoft .NET Framework2.0或者版本过旧。请点击“确定”进行安装,点击“取消”中止安装。]]; 118 119 local strDialogTitle = "必需的技术文件"; 120 121 local bShowUserPrompt = true; -- 设置为 true 来询问用户是否安装模块 122 123 local bRunInstallFile = true; -- 设置默认选择 (是否默认运行安装) 124 125 local strRuntimeSupportFolder = SessionVar.Expand("%TempLaunchFolder%\\dotnet2_0"); 126 127 local strFileToRun = strRuntimeSupportFolder.."\\dotnetfx.exe"; 128 129 ----------------------------------------------------------------------------------------- 130 131 -- 安装已启动。 132 133 SetupData.WriteToLogFile("成功\tdotnet2_0 模块:安装脚本已启动。\r\n", true); 134 135 -- 删除临时文件和运行时支持文件夹 (同时进行错误检查) 136 137 local function PerformCleanUp() 138 139 File.Delete(strFileToRun); 140 141 error = Application.GetLastError(); 142 143 if error ~= 0 then 144 145 SetupData.WriteToLogFile("错误\tdotnet2_0 模块:无法删除临时文件 (".._tblErrorMessages[error]..")\r\n", true); 146 147 end 148 149 Folder.Delete(strRuntimeSupportFolder); 150 151 error = Application.GetLastError(); 152 153 if error ~= 0 then 154 155 SetupData.WriteToLogFile("错误\tdotnet2_0模块:无法删除临时文件夹 (".._tblErrorMessages[error]..")\r\n", true); 156 157 end 158 159 end 160 161 -- 是否显示对话框来询问用户是否安装模块。 162 163 if(bShowUserPrompt)then 164 165 local nDialogResult = Dialog.Message(strDialogTitle,strMessage,MB_OKCANCEL,MB_ICONEXCLAMATION); 166 167 if(nDialogResult == IDOK)then 168 169 -- 用户选择安装模块。 170 171 bRunInstallFile = true; 172 173 -- 用户要安装它 174 175 SetupData.WriteToLogFile("成功\tdotnet2_0 模块:用户已确认,准备安装。\r\n", true); 176 177 else 178 179 -- 用户不安装模块。 180 181 bRunInstallFile = false; 182 183 -- 用户回答否 184 185 SetupData.WriteToLogFile("成功\tdotnet2_0 模块:用户不安装模块。\r\n", true); 186 187 end 188 189 end 190 191 -- 检查用户是否要安装运行时。 192 193 if(bRunInstallFile)then 194 195 -- 开始! 196 197 SetupData.WriteToLogFile("成功\tdotnet2_0模块:正在运行dotnet2_0 安装程序。\r\n", true); 198 199 -- “/R:N”命令行参数告诉 VB 安装程序若需要的话不要显示重启屏幕。 200 201 -- 我们将检测整个安装进程返回代码,若需要的话,还设置内部 _NeedsReboot 变量。 202 203 -- 【注意】在静默方式下,你不能添加命令行参数“/Q”来运行安装 204 205 local nResult = File.Run(strFileToRun,"/R:N","",SW_SHOWNORMAL,true); 206 207 if(nResult == 3010)then 208 209 -- VB 安装指明它需要重启才能完成 210 211 -- 设置 Setup Factory 的重启变量,以便在安装结束时重启 212 213 _NeedsReboot = true; 214 215 -- 需要重启 216 217 SetupData.WriteToLogFile("成功\tdotnet2_0 模块:dotnet2_0 安装程序已告知它需要重启。\r\n", true); 218 219 end 220 221 -- 删除运行时安装程序文件,并删除临时文件夹 222 223 PerformCleanUp(); 224 225 -- 全部完成! 226 227 SetupData.WriteToLogFile("成功\tdotnet2_0模块:dotnet2_0运行时安装完毕。\r\n", true); 228 229 else 230 231 -- 用户不想安装运行时,那么删除运行时安装程序文件, 232 233 -- 并删除临时文件夹,然后退出安装程序。 234 235 PerformCleanUp(); 236 237 -- 全部完成! 238 239 SetupData.WriteToLogFile("成功\tdotnet2_0 模块:dotnet2_0 运行时未安装。\r\n", true); 240 241 Application.Exit(); 242 243 end 244 245 </InstallScript> 246 247 <SupportFiles> 248 249 <File>#SUFDIR#\Dependencies\dotnet2_0\dotnetfx.exe</File> 250 251 </SupportFiles> 252 253 </Dependency> 254 255 </DependencyTemplate>
然后再资源-从属中添加.netframework就行了。
|
|
CALENDER
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
26 | 27 | 28 | 29 | 30 | 31 | 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 | 1 | 2 | 3 | 4 | 5 | 6 |
|
常用链接
留言簿(3)
随笔档案
搜索
最新评论

阅读排行榜
评论排行榜
Powered By: 博客园 模板提供:沪江博客
|