CrazyMetal
CrazyMetal

Reputation: 193

Inno Setup: restart during setup process won't start after reboot

I've made a installer using Inno Setup, and I need to restart computer after some files was run, so I used the solution from this post.

The inno setup sample 'CodePrepareToInstall.iss' works fine, so I used the code for my test installation but my installer don't start after computer reboots.

Both installer (inno demo and my test) add a registry entry in 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce', the only difference is the added value. My sting ist much longer than the added string from inno demo.

Is there a value legth limitation in 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"

Upvotes: 4

Views: 2435

Answers (1)

CrazyMetal
CrazyMetal

Reputation: 193

Figured it out. Windows has a 256 character limit on commands ran from the RunOnce registry in HKLU or HKLM.

So I decided to create a batch file that starts my installer and delete it self afterwards. So I just had to pass the path of the batch to the RunOnce registry.

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;

Batch file:

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

Upvotes: 4

Related Questions