If you want to detect, if there is a pending rename that requires a restart, query PendingFileRenameOperations
registry value.
See also How to find out if an MSI I just installed requested a Windows reboot?
function IsRestartPending: Boolean; var S: string; begin if RegQueryMultiStringValue( HKLM, ‘SYSTEMCurrentControlSetControlSession Manager‘, ‘PendingFileRenameOperations‘, S) then begin Log(Format(‘PendingFileRenameOperations value exists with value [%s]‘, [S])); Result := (Trim(S) <> ‘‘); { This additional check is probably not needed } end else begin Log(‘PendingFileRenameOperations value does not exist‘); Result := False; end; end; function InitializeSetup(): Boolean; begin if IsRestartPending then begin MsgBox(‘Restart your machine please‘, mbError, MB_OK); Result := False; Exit; end; Result := True; end;