安装包制作工具 SetupFactory使用3:打包依赖环境到安装包中

一、打包.net framework 4.0运行环境到依赖中

先点开“从属”设置:
在这里插入图片描述
添加从属文件.net 4
在这里插入图片描述
编辑添加的从属文件,指定.net framework 4.0的安装包
在这里插入图片描述
完成!

二、打包.net framework 4.6.1运行环境到安装包中

此时不能再通过“从属”文件设置,因为setupfactory支持的最高到4.0,此时怎么办呢?

2.1 点开“初始文件”设置

在这里插入图片描述

2.2 在安装前自动检测.net环境,如果没有.net framework 4.6就自动安装

在这里插入图片描述
这里附上检测.net版本的脚本:(其他版本的自行查看注册表)

//.net 4.0
result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.0");
// .net 4.5.2
result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.5.2");
//.net 4.5.3
result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.5.3");
//.net 4.6
result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.6");
//.net 4.6.1
result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.6.1");

三、安装时检测系统如果没有.net 4.0运行环境,就自动下载安装

测试不能使用“从属”、也不能使用“初始文件”,只能自己在安装前检测了,操作如下:
在这里插入图片描述
完整的脚本如下:

hasInstalled = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.0");
if hasInstalled == false then
 result = Dialog.Message("安装提示", "运行本软件需要安装.Net框架4.0版,是否从网络中下载并安装?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1)
 if result == IDYES then 
   -- Show the StatusDlg
   SetupData.WriteToLogFile("用户选择了下载安装.net framework4.0./r/n", true); 
   StatusDlg.Show(MB_ICONINFORMATION, false);
   StatusDlg.ShowCancelButton(true, "取消");
   
   -- Set statusdlg title and message
   StatusDlg.SetTitle("下载所需文件 . . . ");
   -- Set meter range (max range = 65534)
   StatusDlg.SetMeterRange(0, 100);  
   -- Download a file from the internet to the user's computer
   -- Uses DownloadCallback() as the callback function
   SetupData.WriteToLogFile("开始下载./r/n", true); 
   HTTP.DownloadSecure("https://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe", SessionVar.Expand("%TempFolder%/dotNetFx40_Full_x86_x64.exe"), MODE_BINARY, 3000, 443, nil, nil, DownloadCallback);
   SetupData.WriteToLogFile("下载完毕./r/n", true); 
   SetupData.WriteToLogFile(SessionVar.Expand("%TempFolder%/dotNetFx40_Full_x86_x64.exe"))
   -- Hide the StatusDlg
   StatusDlg.Hide();
   Shell.Execute(SessionVar.Expand("%TempFolder%/dotNetFx40_Full_x86_x64.exe"), "open", "", "", SW_SHOWNORMAL)
 else
  Application.Exit(0);
 end
end

-- Callback function for HTTP.Download
function DownloadCallback (nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message)
    SetupData.WriteToLogFile("下载回调:./r/n", true); 
    -- Convert total and downloaded bytes into formatted strings
    sDownloaded = String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true);
    sTotal = String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true);
    -- Output time left, formatted.
    StatusDlg.SetMessage("正在下载文件 . . . 剩余时间: " .. SecondsLeftFormat);    
    -- Output formatted sizes to user through statusdlg status text
    StatusDlg.SetStatusText("已下载: " .. sDownloaded .. " / " .. sTotal);
    -- Set meter position (fraction downloaded * max meter range)
    StatusDlg.SetMeterPos((nDownloaded / nTotal) * 100);
end
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
.NET 4 dotnet4 Friday, December 08, 2017 .Net4.0°²×°¼ì²â function isDotNet_Installed() -- .Net 4 Reg Key local DotNet_Key = "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"; --Check to see if the registry key exists local DotNet_Registry = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, DotNet_Key); if (DotNet_Registry == false) then -- The registry key does not exist -- Run the .NET Installation script -- Output to the log file that .NET could not be found, so it will be installed. SetupData.WriteToLogFile("Info\t.NET 4 Module: No version of .NET 4 was found. .NET 4 will be installed.\r\n", true); return false; else -- The key does exist -- Get the .NET install success value from the registry local DotNet_Install_Success = Registry.GetValue(HKEY_LOCAL_MACHINE, DotNet_Key, "Install", true); if (DotNet_Install_Success == "1") then -- Check the version key. local DotNet_Install_Version = Registry.GetValue(HKEY_LOCAL_MACHINE, DotNet_Key, "Version", true); -- Compare the returned value against the needed value Compare = String.CompareFileVersions(DotNet_Install_Version, "4.0.30319"); if (Compare == 0 or Compare == 1) then -- .NET version 4 is installed already SetupData.WriteToLogFile("Info\t.NET 4 Module: .NET version 4 is installed already\r\n", true); return true; else SetupData.WriteToLogFile("Info\t.NET 4 Module: A lesser version of .NET 4 was found on the users system.\r\n", true); return false; end else -- The success value wasn't found -- Run the .NET Installation script -- Output to the log file that .NET could not be found, so it will be installed. SetupData.WriteToLogFile("Info\t.NET 4 Module: No version of .NET 4 was found. .NET 4 will be installed.\r\n", true); return f

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jackletter

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值