如何使用InnoSetup进行静默安装? [英] How to make the silent installation by using InnoSetup?
问题描述
我需要使用下一个,下一个安装向导过程来开始我的应用程序的静默安装.请任何人帮助我.
I need to start the silent installation for my application with out next , next installation wizard process . Please any one help me.
推荐答案
Proper way to run the setup in silent mode is, and always be executing it with /SILENT
command line parameter. For instance this way:
setup.exe /SILENT
在我的注释中澄清了您的要求之后,您实际上想要构建一个安装程序,该安装程序将在无提示模式下运行而无需提及命令行参数.当前,没有内置的方法告诉编译器您要构建静默安装程序,因此我们需要通过使用
After we clarified your requirement in comments I see, that you actually want to build a setup, which will run in silent mode without the mentioned command line parameter. Currently, there's no built-in way to tell the compiler, that you want to build a silent setup, so we need to workaround this by re-running the setup with the /SILENT
command line parameter when the setup is being initialized.
以下脚本显示了此解决方法:
The following script shows this workaround:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
type
HINSTANCE = THandle;
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE;
external 'ShellExecute{#AW}@shell32.dll stdcall';
function InitializeSetup: Boolean;
begin
// if this instance of the setup is not silent which is by running
// setup binary without /SILENT parameter, stop the initialization
Result := WizardSilent;
// if this instance is not silent, then...
if not Result then
begin
// re-run the setup with /SILENT parameter; because executing of
// the setup loader is not possible with ShellExec function, we
// need to use a WinAPI workaround
if ShellExecute(0, '', ExpandConstant('{srcexe}'), '/SILENT', '',
SW_SHOW) <= 32
then
// if re-running this setup to silent mode failed, let's allow
// this non-silent setup to be run
Result := True;
end;
end;
这篇关于如何使用InnoSetup进行静默安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!