【问题标题】:Inno Setup: restart during setup process won't start after rebootInno Setup:在安装过程中重新启动将不会在重新启动后启动
【发布时间】:2015-06-14 17:52:58
【问题描述】:

我使用 Inno Setup 制作了安装程序,运行某些文件后我需要重新启动计算机, 所以我使用了this post的解决方案。

inno 安装示例 'CodePrepareToInstall.iss' 工作正常,所以我使用代码进行测试安装,但我的安装程序在之后没有启动 计算机重新启动。

安装程序(inno 演示和我的测试)都在 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce' 中添加了一个注册表项,唯一的区别是 附加值。我的刺痛比 inno 演示中添加的字符串要长得多。

registry/runonce 中是否存在值长度限制?

Inno Demo Value:
"C:\Users\Admin\Documents\Inno Setup Examples Output\setup.exe" /restart=1 /LANG=default /DIR="C:\Program Files (x86)\My Program" /GROUP="My Program"

My Installer Value:
"C:\Users\Admin\Documents\Inno Setup Projekte\Treiber Test\bin\Driver Test Setup.exe" /restart=1 /LANG=german /DIR="C:\Driver" /GROUP="Driver Test Setup" /TYPE="full" /COMPONENTS="1234driverinstaller,audio,bluetooth,chipset,devicepowermanager,gps,inputmanagementservice,modem,lan,1234powerplan,touchscreen,vga,wlan,wwan,1234products"

【问题讨论】:

  • 如果您手动运行该命令是否有效?
  • 是的,如果我从注册表中复制值并将其传递到运行中,安装程序就会出现并且工作正常。如果我在“/Group”部分之后删除值,它也会在计算机重新启动后正常运行。

标签: windows installation registry inno-setup reboot


【解决方案1】:

想通了。 Windows 对从 HKLU 或 HKLM 中的 RunOnce 注册表运行的命令有 256 个字符的限制。

所以我决定创建一个批处理文件来启动我的安装程序并在之后自行删除它。所以我只需要将批处理的路径传递给 RunOnce 注册表。

InnoScript:

procedure CreateRunOnceEntry;
var
    RunOnceData: String;
begin
    RunOnceData := 'echo off' + #13#10;
    RunOnceData := RunOnceData + 'start "" ';
    RunOnceData := RunOnceData + Quote(ExpandConstant('{srcexe}')) + ' /restart=1';
    RunOnceData := AddParam(RunOnceData, 'LANG', ExpandConstant('{language}'));
    RunOnceData := AddParam(RunOnceData, 'DIR', Quote(WizardDirValue));
    RunOnceData := AddParam(RunOnceData, 'GROUP', Quote(WizardGroupValue));
    if WizardNoIcons then
        RunOnceData := AddSimpleParam(RunOnceData, 'NOICONS');
    RunOnceData := AddParam(RunOnceData, 'TYPE', Quote(WizardSetupType(False)));
    RunOnceData := AddParam(RunOnceData, 'COMPONENTS', Quote(WizardSelectedComponents(False)));
    RunOnceData := AddParam(RunOnceData, 'TASKS', Quote(WizardSelectedTasks(False)));
    RunOnceData := RunOnceData + #13#10 + 'start /b cmd.exe /c del %0' + #13#10 + 'exit';

    SaveStringToFile(ExpandConstant('{commonappdata}\StartInstallation.cmd'), RunOnceData, True);

    if not IsWin64 then
        RegWriteStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\RunOnce', RunOnceName, ExpandConstant('{commonappdata}\StartInstallation.cmd'));
    if IsWin64 then
        RegWriteStringValue(HKLM, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce', RunOnceName, ExpandConstant('{commonappdata}\StartInstallation.cmd'));
end;

批处理文件:

echo off
start "" "C:\Users\Admin\Documents\Inno Setup Projekte\Treiber Test\bin\Driver Test Setup.exe" /restart=1 /LANG=german /DIR="C:\Driver" /GROUP="Driver Test Setup" /TYPE="full" /COMPONENTS="1234driverinstaller,audio,bluetooth,chipset,devicepowermanager,gps,inputmanagementservice,modem,lan,1234powerplan,touchscreen,vga,wlan,wwan,1234products"
start /b cmd.exe /c del %0
exit

【讨论】:

  • 我们应该将此报告为错误,因为这很容易发生。作为 Inno Setup 实施的解决方法,我建议使用任务调度程序。附言永远不要访问Wow6432Node。如果要访问某些注册表视图,请使用 HKLM32HKLM64 根键。
  • 是的,你是对的,我会将此报告为错误并使用 HKLM32 或 HKLM64 insted。谢谢=)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-29
  • 2020-09-09
  • 1970-01-01
  • 2020-10-09
  • 1970-01-01
相关资源
最近更新 更多