如何使 Inno Setup 在执行长时间 Exec 时看起来不被冻结?

发布于 2024-07-13 20:22:13 字数 742 浏览 4 评论 0 原文

Exec 正在安装 .NET 3.5,并且输出脚本基于以下脚本: http://www.blackhillsoftware .com/blog/2006/06/26/using-innosetup-with-the-dotnet-framework/

问题在于它使用了 ewWaitUntilTermulated ,因为我们需要捕获退出代码。 事实上,我们运行它 /passive /norestart 这样就减少了用户的工作量(也许我们不应该?),

我能想到的最简单的选择是在安装 .NET 时隐藏窗口并在完成后再次显示它,但我不知道该怎么做。

理想的解决方案是显示进度页面,但似乎不可能,因为我们需要立即返回,但在进程退出时仍会收到通知并捕获退出代码,否则我们会只是有一个永恒的进度条。

关于如何解决这个问题有什么想法吗?

编辑:最小化可能会更好,但也不知道如何做到这一点。 我们确实显示一条消息,通知用户该过程可能需要 10-20 分钟,但问题是主设置表单完全冻结,无法移动、最小化或对其执行任何操作。 另外,在速度较慢的计算机上运行 /passive .NET 安装程序实际上在一两分钟内不会显示任何进度。

The long Exec is installing .NET 3.5, and out script is based off this one:
http://www.blackhillsoftware.com/blog/2006/06/26/using-innosetup-with-the-dotnet-framework/

The problem is that it's using ewWaitUntilTerminated because we need to capture the exit code. It's made a little worse by the fact that we're running it /passive /norestart so that it's less work on the user's part (Maybe we shouldn't?)

The easiest option I could think of is to hide the window while it's installing .NET and showing it again after it's done, but I'm not sure how to do that.

The ideal solution would be to show a progress page, but it doesn't seem like it'd be possible since we'd need to return right away but somehow still be notified when the process exits and capture the exit code otherwise we'd just have an eternal progress bar.

Any ideas on how to go about this?

Edit: Minimizing would probably be better, but not sure how to do that either. We do display a message informing the user that the process may take 10-20 minutes, however the problem is that the main setup form is completely frozen, can't move, minimize or do anything with it. Also running /passive the .NET installer doesn't actually show any progress for a good minute or two on a slower machine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

烂柯人 2024-07-20 20:22:13

使 Inno Setup“看起来不冻结”的一种方法是添加一个“假”进度指示器,例如选框,以显示正在发生的事情。 但这并不能解决“窗口不可拖动/可移动”的问题。

因此,另一种方法是在执行长时间运行的进程时真正解冻 Inno Setup GUI:
“长时间运行的进程”是通过 ShellExecuteEx() 执行的。
然后安装程序使用 while 循环和条件
WaitForSingleObject 和非常短的超时
执行AppProcessMessage

AppProcessMessage 本身就是一个辅助函数。 它使用“通用”代码重新创建一个 Application.ProcessMessages 式的过程,使用 WinAPI 函数 PeekMessage()TranslateMessage() 和 <代码>DispatchMessage()。
它的工作是充当 Inno Setup GUI 的消息泵。

这个技巧使窗口再次响应/可拖动,
而“长时间运行的进程”是在后台处理的。

这是执行循环的源代码:

if ShellExecuteEx(ExecInfo) then
begin
  while WaitForSingleObject(ExecInfo.hProcess, 100) = WAIT_TIMEOUT
  do begin
      AppProcessMessage;
      WizardForm.Refresh();
  end;
  CloseHandle(ExecInfo.hProcess);
end;

以下 unzip.iss 的 GIST 包含独立 用于执行 7zip 而不阻塞 Inno Setup GUI 的解压缩帮助程序,包括使用 AppProcessMessage 函数的零碎内容。

在这种情况下,“unzip”只是一个示例,您可以将执行的应用程序替换为任何内容,.NET 安装程序或任何其他长时间运行的任务。

One way of making Inno Setup "not look frozen" is to add a "fake" progress indicator, like a marquee, to show that something is going on. But this won't solve the "window not dragable / moveable" problem.

So, another way is to really unfreeze the Inno Setup GUI, while a long running process is executed:
The "long running process" is executed via ShellExecuteEx().
Then the installer uses a while loop with the condition
WaitForSingleObject and a very minimal timeout
to execute AppProcessMessage.

AppProcessMessage is itself a helper function. It uses "generic" code to recreate a Application.ProcessMessages-ish procedure, using the WinAPI function PeekMessage(), TranslateMessage() and DispatchMessage().
Its job is to be the message pump to the Inno Setup GUI.

This trick makes the window responsive/draggable again,
while the "long running process" is processed in the background.

This is the source for the execution loop:

if ShellExecuteEx(ExecInfo) then
begin
  while WaitForSingleObject(ExecInfo.hProcess, 100) = WAIT_TIMEOUT
  do begin
      AppProcessMessage;
      WizardForm.Refresh();
  end;
  CloseHandle(ExecInfo.hProcess);
end;

The following GIST for unzip.iss contains the code for a standalone Unzip Helper for executing 7zip without blocking the Inno Setup GUI, including the bits and pieces for working with the AppProcessMessage function.

In this case "unzip" is just an example and you might replace the executed application with whatever, a .NET installer or any other long running task.

黎歌 2024-07-20 20:22:13

尽管这可能很容易,但我不建议在 .Net 安装程序运行时隐藏安装程序。 我见过其他安装程序这样做,当它发生时,我认为安装已经完成,然后当我发现它实际上没有完成时我很困惑。 (当安装真正完成时,我也不能确定这一点。也许它又隐藏起来了。)

您可以在 Inno Setup 向导中显示自定义页面。 让这样的页面显示进度条并保持其准确可能是一个挑战,但至少您可以在向导页面上显示一条消息,说明您的安装程序正在等待 .Net 安装程序,然后再继续。 请参阅帮助文件的“使用自定义向导页面”部分。

Although it probably would be easy, I don't recommend hiding your installer while the .Net installer runs. I've seen other installers do that, and when it happens, I think the installation is finished, and then I'm confused when I find that it's really not. (And when the installation really is finished, I can't be sure of that, either. Maybe it just hid itself again.)

You can display custom pages in the Inno Setup wizard. Making such a page show a progress bar and keeping it accurate would probably be a challenge, but at least you could display a message on the wizard page saying that your installer is waiting for the .Net installer before proceeding. See the "Using Custom Wizard Pages" section of the help file.

憧憬巴黎街头的黎明 2024-07-20 20:22:13

您可以通过调用简单地隐藏安装程序向导表单,

WizardForm.Hide;
Exec(...);
WizardForm.Show;

尽管我同意这并不是很漂亮。

You can simply hide the installer wizard form by calling

WizardForm.Hide;
Exec(...);
WizardForm.Show;

though I agree that this is not really pretty.

毁虫ゝ 2024-07-20 20:22:13

我们需要使用几个产品来安装 .NET,并采取了两种方法:

  • 使用 Innosetup 安装 .NET 时,我们让用户知道安装将需要很长时间,并在完成时等待特定消息
  • 我们启动 .NET 设置时没有任何标志来强制客户端通过它。 这样,如果他们更倾向于技术,他们就会知道为什么安装需要这么长时间。

老实说,我们在第二个选项上运气更好,特别是现在更多的系统管理员似乎在一定程度上锁定了桌面。

We've needed to install .NET with a couple products, and have taken two approaches:

  • When installing .NET with Innosetup, we let the user know that the installation will take a long time, and to expect a certain message when it is complete
  • We start the .NET set up without any flags to force the client through it. This way if they're more technically inclined they know why the install is taking so long

We've honestly had better luck with the 2nd option, particularly now that more system admins seem to lock down desktops to a certain degree.

凯凯我们等你回来 2024-07-20 20:22:13

自从你问这个问题以来已经过去了 5 年,但无论如何,这是我的答案。

在调用 Exec() 之前,您可以设置 Inno Setup 将在主进度条上方显示的消息,如下所示:

WizardForm.StatusLabel.Caption := 'Installing .NET Framework 3.5. Please wait, this can take up to 1 hour...';

It's been 5 years since you've asked the question but here is my answer anyway.

Before calling Exec() you can set the message that will be shown by Inno Setup above the main progress bar like this:

WizardForm.StatusLabel.Caption := 'Installing .NET Framework 3.5. Please wait, this can take up to 1 hour...';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文