मैं इसे इस तरह से किया था:
लिखें त्रुटि संदेश (या तो पुष्टि संदेश या सिर्फ सूचना संदेश गर्भपात) अस्थायी फ़ाइल {tmp}\install.error
करने के लिए SaveStringToUTF8File
प्रक्रिया के साथ Inno सेटअप के BeforeInstall
पैरामीटर का उपयोग कर। आप इनो सेटअप के स्थिरांक का उपयोग कर सकते हैं, जैसे {cm:YourCustomMessage}
।
वांछित प्रोग्राम चलाने के लिए विंडोज कमांड खोल cmd.exe /s /c
का उपयोग करें। &&
- https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx के साथ del
कमांड के सशर्त निष्पादन का भी उपयोग करें। तो आदेश सफल होने पर त्रुटि संदेश फ़ाइल हटा दी जाएगी (निकास कोड 0)। कृपया cmd.exe /s /c
में हैंडलिंग विशेष उद्धरणों से अवगत रहें। उदाहरण के रूप में नीचे कोड का प्रयोग करें। त्रुटि संदेश फ़ाइल {tmp}\install.error
की
चेक अस्तित्व Inno सेटअप के या तो ConfirmInstallAbortOnError
या NotifyInstallAbortOnError
त्रुटि गंभीरता के आधार पर प्रक्रियाओं के साथ AfterInstall
पैरामीटर का उपयोग कर। वे उचित अधिसूचना या पुष्टि (और लॉग फ़ाइल के वैकल्पिक पेश) के साथ स्थापित रद्द कर देगा और Exec(ExpandConstant('{uninstallexe}'), ...
ShouldAbortInstallation
वैश्विक चर का उपयोग कर स्थिति रखने के लिए प्रयोग किया जाता है रोलबैक प्रदर्शन करते हैं। अंतिम पृष्ठ को छिपाने के लिए इनो सेटअप का ShouldSkipPage(PageID: Integer)
फ़ंक्शन का उपयोग किया जाता है। [Run]
अनुभाग में सभी आदेश पैरामीटर CheckInstallationIsNotAborted
फ़ंक्शन के साथ उपयोग करना चाहिए। यह किसी बिंदु पर विफलता के बाद उनके निष्पादन को रोक देगा।
नीचे उदाहरण देखें। उम्मीद है की यह मदद करेगा।
[CustomMessages]
InstallAbortOnErrorConfirmationMessage=An error has occurred during setup.%nAbort installation?
InstallAbortOnErrorNotificationMessage=An error has occurred during setup.%nInstallation will be aborted.
RunProgram1ErrorMsg=Post installation phase 1 failed. Should abort install?
RunProgram2ErrorMsg=Post installation phase 2 failed. Installation will be aborted. Please, contact tech support.
RunProgram1StatusMsg=Post installation phase 1 is in progress
RunProgram2StatusMsg=Post installation phase 2 is in progress
[Run]
; Write error text to file. Delete file on succeed. Abort installation if file exists after command execution.
Filename: "cmd.exe"; Parameters: "/s /c "" ""{app}\program1.exe"" /param1 /param2:""val2"" && del /F /Q ""{tmp}\install.error"" """; \
WorkingDir:"{app}"; Flags: runhidden; \
BeforeInstall: SaveStringToUTF8File('{tmp}\install.error', '{cm:RunProgram1ErrorMsg}', False); \
AfterInstall: ConfirmInstallAbortOnError('{tmp}\install.error', '{app}\logs\setup.log'); \
StatusMsg: "{cm:RunProgram1StatusMsg}"; \
Check: CheckInstallationIsNotAborted;
Filename: "cmd.exe"; Parameters: "/s /c "" ""{app}\program2.exe"" && del /F /Q ""{tmp}\install.error"" """; \
WorkingDir:"{app}"; Flags: runhidden; \
BeforeInstall: SaveStringToUTF8File('{tmp}\install.error', '{cm:RunProgram2ErrorMsg}', False); \
AfterInstall: NotifyInstallAbortOnError('{tmp}\install.error', '{app}\logs\setup.log'); \
StatusMsg: "{cm:RunProgram2StatusMsg}"; \
Check: CheckInstallationIsNotAborted;
[Code]
var
ShouldAbortInstallation: Boolean;
procedure SaveStringToUTF8File(const FileName, Content: String; const Append: Boolean);
var
Text: array [1..1] of String;
begin
Text[1] := Content;
SaveStringsToUTF8File(ExpandConstant(FileName), Text, Append);
end;
function LoadAndConcatStringsFromFile(const FileName: String): String;
var
Strings: TArrayOfString;
i: Integer;
begin
LoadStringsFromFile(FileName, Strings);
Result := '';
if High(Strings) >= Low(Strings) then
Result := Strings[Low(Strings)];
for i := Low(Strings) + 1 to High(Strings) do
if Length(Strings[i]) > 0 then
Result := Result + #13#10 + Strings[i];
end;
procedure ConfirmInstallAbortOnError(ErrorMessageFile, LogFileToShow: String);
var
ErrorCode: Integer;
ErrorMessage: String;
begin
ErrorMessageFile := ExpandConstant(ErrorMessageFile);
LogFileToShow := ExpandConstant(LogFileToShow);
Log('ConfirmInstallAbortOnError is examining file: ' + ErrorMessageFile);
if FileExists(ErrorMessageFile) then
begin
Log('ConfirmInstallAbortOnError: error file exists');
{ Show log file to the user }
if Length(LogFileToShow) > 0 then
ShellExec('', LogFileToShow, '', '', SW_SHOW, ewNoWait, ErrorCode);
ErrorMessage := LoadAndConcatStringsFromFile(ErrorMessageFile);
if Length(ErrorMessage) = 0 then
ErrorMessage := '{cm:InstallAbortOnErrorConfirmationMessage}';
if MsgBox(ExpandConstant(ErrorMessage), mbConfirmation, MB_YESNO) = IDYES then
begin
Log('ConfirmInstallAbortOnError: should abort');
ShouldAbortInstallation := True;
WizardForm.Hide;
MainForm.Hide;
Exec(ExpandConstant('{uninstallexe}'), '/SILENT', '', SW_HIDE,
ewWaitUntilTerminated, ErrorCode);
MainForm.Close;
end;
end;
Log('ConfirmInstallAbortOnError finish');
end;
procedure NotifyInstallAbortOnError(ErrorMessageFile, LogFileToShow: String);
var
ErrorCode: Integer;
ErrorMessage: String;
begin
ErrorMessageFile := ExpandConstant(ErrorMessageFile);
LogFileToShow := ExpandConstant(LogFileToShow);
Log('NotifyInstallAbortOnError is examining file: ' + ErrorMessageFile);
if FileExists(ErrorMessageFile) then
begin
Log('NotifyInstallAbortOnError: error file exists');
{ Show log file to the user }
if Length(LogFileToShow) > 0 then
ShellExec('', LogFileToShow, '', '', SW_SHOW, ewNoWait, ErrorCode);
ErrorMessage := LoadAndConcatStringsFromFile(ErrorMessageFile);
if Length(ErrorMessage) = 0 then
ErrorMessage := '{cm:InstallAbortOnErrorNotificationMessage}';
MsgBox(ExpandConstant(ErrorMessage), mbError, MB_OK);
Log('NotifyInstallAbortOnError: should abort');
ShouldAbortInstallation := True;
WizardForm.Hide;
MainForm.Hide;
Exec(ExpandConstant('{uninstallexe}'), '/SILENT', '', SW_HIDE,
ewWaitUntilTerminated, ErrorCode);
MainForm.Close;
end;
Log('NotifyInstallAbortOnError finish');
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := ShouldAbortInstallation;
end;
function CheckInstallationIsNotAborted(): Boolean;
begin
Result := not ShouldAbortInstallation;
end;
इसी प्रकार का प्रश्न: http://stackoverflow.com/questions/582452/msi-return-codes-in-inno-setup – mghie
inno को डिफ़ॉल्ट रूप से डिफ़ॉल्ट रूप से चेतावनी दी जानी चाहिए जब यह होता है ... yipes – rogerdpack
यह भी देखें [प्रक्रिया से बाहर निकलने का उपयोग करना कोड [[रन \]] में एक विशिष्ट फ़ाइल के लिए त्रुटि संदेश दिखाने के लिए कोड (http://stackoverflow.com/q/9621099/850848) और [इनो सेटअप: इंस्टॉल के दौरान सेटअप को निरस्त/समाप्त कैसे करें?] (http://stackoverflow.com/q/6345920/850848) –