日期:2014-05-20  浏览次数:20863 次

使用inno setup打包,自动安装.Net Framework3.5无法执行。
各位大侠,本人在使用inno setup打包,自动安装.Net Framework3.5遇到问题。请各位大侠施以援手,感激不尽。
考虑在所有程序安装前先安装.Net Framework3.5,事先在需要安装的电脑上放置程序dotnetfx35.exe,由程序调用安装。

INNO SETUP脚本如下:
function InitializeSetup: Boolean;
var Path:string ;
  ResultCode: Integer;
  dotNetV35PackFile:string;

begin
  if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\.NETFramework\policy\v3.5')
  then
  begin
  Result := true;
  end
  else
  begin
  if MsgBox('系统检测到您没有安装.Net Framework3.5,是否立即安装?', mbConfirmation, MB_YESNO) = idYes then
  begin
  dotNetV35PackFile:='{src}\dotnetfx35.exe';
  Path := ExpandConstant(dotNetV35PackFile);
  if(FileOrDirExists(Path)) then
  begin
  Exec(Path, '/q', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\.NETFramework\policy\v3.5') then
  begin
  Result := true;
  end
  end
  end
  else
  begin
  MsgBox('没有安装.Net Framework3.5环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
  Result := false;
  end;
  end;
end;

理论上来说,只要保证安装包文件和dotnetfx35.exe在同一路径下就可以执行。但实际安装过程中,从进程可看到dotnetfx35setup.exe和dotnetfx35.exe,但没有任何动静;如果手动安装,则进入extraction,继而安装。

------解决方案--------------------
Exec(ExpandConstant('{src}\dotnetfx35.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);