在Inno Setup中进行安装之前,先检测重启是否挂起 [英] Detect if restart is pending before installing in Inno Setup
问题描述
如果重新启动/重新启动已经挂起/需要,是否可以防止安装?
Is there a way to prevent installation if a reboot/restart is already pending/required?
我们的安装程序安装了SQL Server Express,并且如果系统中有挂起的重新启动,有时它会拒绝这样做. Inno Setup可以检测到这种情况,以便在安装我们的软件之前告诉用户重新启动吗?
Our setup installs SQL Server Express and it will sometimes refuse to do so if there is a pending restart in the system. Can Inno Setup detect this condition so I can tell the user to reboot before installing our software?
我了解 MakePendingFileRenameOperationsChecksum
,但是通常提到它检测在安装过程中是否出现要求重新启动的条件.可以在使用之前吗?
I know about MakePendingFileRenameOperationsChecksum
but it's usually mentioned to detect whether the reboot required condition appeared DURING the setup. Can it be used BEFORE?
推荐答案
如果要检测是否存在需要重新启动的挂起重命名,请查询PendingFileRenameOperations
注册表值.
If you want to detect, if there is a pending rename that requires a restart, query PendingFileRenameOperations
registry value.
另请参阅如何确定我刚刚安装的MSI是否要求Windows重新启动?
function IsRestartPending: Boolean;
var
S: string;
begin
if RegQueryMultiStringValue(
HKLM, 'SYSTEM\CurrentControlSet\Control\Session 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;
如果您需要测试可能需要重新启动的其他操作,则必须使用@Jerry修改答案以设置Inno.
这篇关于在Inno Setup中进行安装之前,先检测重启是否挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!