2014-02-05 32 views
7

我需要在下一个安装向导过程中为我的应用程序启动无提示安装。请任何人帮助我。如何使用InnoSetup进行无提示安装?

enter image description here

+4

使用['/SILENT'](http://jrsoftware.org/ishelp/topic_setupcmdline.htm#SILENT)命令行参数。 – TLama

+0

我是inno脚本中的新手。请发送静默安装脚本 – satheesh

+0

没有脚本。静音模式就是如何执行设置的方式。你只需要一个设置,你可以用'/ SILENT'参数运行。在您的脚本中,您可以有条件地执行某些操作,具体取决于设置是否以静默模式运行。但这取决于你的脚本。 – TLama

回答

13

适当的方式来运行在无声模式是设置,并始终与/SILENT命令行参数来执行它。比如这样:

setup.exe /SILENT 

后,我们阐明您的要求在评论中我看到,你真的想建立一个设置,这将在静音模式下运行,而不提及的命令行参数。目前,没有内置的方法可以告诉编译器,您要构建一个静默设置,所以我们需要通过在初始化安装时使用/SILENT命令行参数重新运行安装程序来解决此问题。

下面的脚本说明此替代方法:

[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; 
+0

当然,如果你真的做到了上述,它会立即让你被标记为恶意软件。 **从来没有**安装人员这样做的一个很好的理由。任何运行安装程序的人都有责任明确请求沉默的行为,假设如果没有请求,则不需要。 – Miral

+2

@Miral,被标记为恶意软件正是需求所应得的。 – TLama

+0

包含上述脚本时出现运行时错误,错误是无法导入shell32 dll。 – satheesh

相关问题