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