懂InnoSetup脚本的请进!

guti_milan 2008-06-14 09:27:30
我写了个 “安装前判断所安装的机器是否有Framework,如果有,则不安装,没有,则先安装Framework”的脚本
但是 在未安装.net框架的机器上 有提示 点“确定"后只是复制dotnetfx.exe到文件夹下面 并没有执行安装
脚本如下

Procedure InstallFrame(FileName:string);
var ResultCode:Integer;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\.NETFramework\policy\v2.0') then
begin
end
else begin
if Msgbox('安装程序检测到本机尚未安装FrameWork,为确保程序正确运行,请点击确定按钮完成FrameWork的安装!',mbConfirmation,MB_OKCANCEL) = IDOK then
begin
if not ShellExec('open',ExpandConstant('"{tmp}\FrameWork\dotnetfx.exe"'),'',ExpandConstant('"{tmp}\FrameWork\"'),SW_SHOW,ewWaitUntilTerminated, ResultCode) then
begin
SysErrorMessage(ResultCode);
end
end
else begin
Msgbox('FrameWork未安装,安装程序可能不能正确运行!',mbConfirmation,MB_OK);
end
end;
end;


有什么不对的地方 请指教 没学过 Pascal 不好意思 献丑了
...全文
170 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
guti_milan 2008-06-14
  • 打赏
  • 举报
回复
 
[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')

加了 红色部分 就不运行InstallFrame了
去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe
请大侠指教 为什么 谢谢!
guti_milan 2008-06-14
  • 打赏
  • 举报
回复
[code=Delphi(Pascal)]
[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')
加了 红色部分 就不运行InstallFrame了
去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe
请大侠指教 为什么 谢谢!
僵哥 2008-06-14
  • 打赏
  • 举报
回复
建议在安装选项当中做文章。也就是安装还是由innosetup来管,你的程序只是通过判断之后给出一个选项的定位。
zwjchina 2008-06-14
  • 打赏
  • 举报
回复
if not ShellExec('open',ExpandConstant('"{tmp}\FrameWork\dotnetfx.exe"'),'',ExpandConstant('"{tmp}\FrameWork\"'),SW_SHOW,ewWaitUntilTerminated, ResultCode) then
我估计是执行这句的时候"{tmp}\FrameWork\"里根本没有dotnetfx.exe

应该需要先把文件释放出来: ExtractTemporaryFile('dotnetfx.exe');

包含'dotnetfx.exe'文件时,最好使用:Source: Path\dotnetfx.exe; DestDir: {sys}; Flags: dontcopy
关键是Flags: dontcopy
guti_milan 2008-06-14
  • 打赏
  • 举报
回复
请懂的 高手 帮看阿 谢谢拉
touchboy 2008-06-14
  • 打赏
  • 举报
回复
留个记号
guti_milan 2008-06-14
  • 打赏
  • 举报
回复
自己搞定了 谢谢拉 很热心 楼上的
zwjchina 2008-06-14
  • 打赏
  • 举报
回复
或者最简单的。但是不是好办法:

[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}"; AfterInstall: InstallFrame('{tmp}\dotnetfx.exe')

写错了,去掉Flags: dontcopy ; 去掉'{tmp}\framework\dotnetfx.exe'中的 framework
zwjchina 2008-06-14
  • 打赏
  • 举报
回复
或者最简单的。但是不是好办法:

[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;AfterInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')
zwjchina 2008-06-14
  • 打赏
  • 举报
回复
加入下面这个Inno默认过程

procedure InitializeWizard();
begin
InstallFrame(...);
end;

当然,最好是能够自己多一个安装提示页,然后在
function NextButtonClick(CurPageID: Integer): Boolean;
procedure CurPageChanged(CurPageID: Integer);
等默认过程中进行处理。

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧