我写了个 “安装前判断所安装的机器是否有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 不好意思 献丑了
但是 在未安装.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 不好意思 献丑了
我估计是执行这句的时候"{tmp}\FrameWork\"里根本没有dotnetfx.exe应该需要先把文件释放出来: ExtractTemporaryFile('dotnetfx.exe');包含'dotnetfx.exe'文件时,最好使用:Source: Path\dotnetfx.exe; DestDir: {sys}; Flags: dontcopy
关键是Flags: dontcopy
[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')
加了 红色部分 就不运行InstallFrame了
去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe
请大侠指教 为什么 谢谢!
[Files]
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;BeforeInstall: InstallFrame('{tmp}\framework\dotnetfx.exe') 加了 红色部分 就不运行InstallFrame了
去掉后 能运行 不过说没有找到 temp里面的 dotnetfx.exe
请大侠指教 为什么 谢谢!
begin
InstallFrame(...);
end;当然,最好是能够自己多一个安装提示页,然后在
function NextButtonClick(CurPageID: Integer): Boolean;
procedure CurPageChanged(CurPageID: Integer);
等默认过程中进行处理。
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}";Flags: dontcopy ;AfterInstall: InstallFrame('{tmp}\framework\dotnetfx.exe')
Source: "D:\framework\dotnetfx.exe" ; DestDir: "{tmp}"; AfterInstall: InstallFrame('{tmp}\dotnetfx.exe') 写错了,去掉Flags: dontcopy ; 去掉'{tmp}\framework\dotnetfx.exe'中的 framework