我写了个 “安装前判断所安装的机器是否有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 不好意思 献丑了

解决方案 »

  1.   

    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
      

  2.   

    建议在安装选项当中做文章。也就是安装还是由innosetup来管,你的程序只是通过判断之后给出一个选项的定位。
      

  3.   

    [code=Delphi(Pascal)]
    [Files]
    Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')
    加了 红色部分 就不运行InstallFrame了
    去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe 
    请大侠指教 为什么 谢谢! 
      

  4.   

     
    [Files] 
    Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe') 加了 红色部分 就不运行InstallFrame了 
    去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe 
    请大侠指教 为什么 谢谢! 
      

  5.   

    加入下面这个Inno默认过程procedure InitializeWizard();
    begin
      InstallFrame(...);
    end;当然,最好是能够自己多一个安装提示页,然后在
    function NextButtonClick(CurPageID: Integer): Boolean; 
    procedure CurPageChanged(CurPageID: Integer); 
    等默认过程中进行处理。
      

  6.   

    或者最简单的。但是不是好办法:[Files] 
    Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;AfterInstall: InstallFrame('{tmp}\framework\dotnetfx.exe') 
      

  7.   

    或者最简单的。但是不是好办法: [Files] 
    Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}"; AfterInstall: InstallFrame('{tmp}\dotnetfx.exe') 写错了,去掉Flags: dontcopy ; 去掉'{tmp}\framework\dotnetfx.exe'中的 framework