一个Setup Factory的Lua脚本

需求是把安装路径中的反斜杠转义成斜杠并写入到配置文件特定的地方去。

读取配置文件 由于配置文件不大 一次性的读入到内存中

local f = io.input(SessionVar.Expand("%AppFolder%\\Common\\conf.xml"), "r");

local r =f:read("*all");

io.close();

修改Lua的简单IO模式下的输出文件 其实就是上面的输入文件

io.output(SessionVar.Expand("%AppFolder%\\Common\\conf.xml"));

SessionVar.Expand("%AppFolder%")是Setup Factory里面的用户选择的安装目录,用Lua的string.gsub方法进行替换
local res = string.gsub(SessionVar.Expand("%AppFolder%"), "\\", "/");

..是字符串连接符
local ptn = "<ComputerURL>" .. res .. "/</ComputerURL>";

回写到输出文件中,达到动态配置的目的

local opr = string.gsub(r, "<ComputerURL></ComputerURL>", ptn);

io.write(opr);
io.close();

脚本配置在On Post install。由SF的lua引擎进行分析并执行

转载于:https://www.cnblogs.com/yujianchi/archive/2011/03/19/1988561.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值