Install Shield静默安装第三方应用

本文详细介绍了如何使用LaunchApplication函数进行第三方应用的静默安装,包括参数设置,如隐藏窗口、等待应用终止等选项。通过指定路径、命令行参数、工作目录和窗口状态,实现自动化安装过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、LaunchAppAndWait函数的第三个参数:传入LAAW_OPTION_HIDDEN即给示隐藏窗口

2、The LaunchApplication function launches and optionally waits for the specified application.

LaunchApplication uses either the Windows API function CreateProcess or the Windows API function ShellExecuteEx (if nOptions includes LAAW_OPTION_USE_SHELLEXECUTE) to launch the specified application. After the application is launched, if the LAAW_OPTION_WAIT option is specified, the installation calls WaitForApplication to wait for the application to terminate; once the process has completed or the specified timeout value has elapsed, the installation continues.
 Syntax

 LaunchApplication( byval string szProgram, byval string szCmdLine, byval string szDirectory, byval number nShowWindow, byval number nTimeOut, byval number nOptions );
 Parameters

 LaunchApplication Parameters 
 Parameter  
 Description

 szProgram  
 Specifies the complete path and file name of the application to be launched.

 If nOptions does not include LAAW_OPTION_USE_SHELLEXECUTE, you can instead specify the file name of the application to be launched in the szCmdLine parameter; if you do so, pass an empty string ("") in the szProgram parameter.

 The szProgram parameter does not support URLs.

 szCmdLine  
 Specifies the command-line parameters to pass to the launched application. To launch the application with no command-line parameters, pass a null string ("").

 If nOptions does not include LAAW_OPTION_USE_SHELLEXECUTE, you can also specify the file name of the application to be launched in the szCmdLine parameter; if you do so, be sure to do the following:
Separate the path to the application and the command line with a single space.
If the fully qualified name of the application includes long folder names and/or a long file name, pass it to LongPathToQuote before adding it to szCmdLine. For example:

 szApplicationPath = WINDIR ^ "Notepad.exe";

 szApplicationCmdLine = SRCDIR ^ "Readme.txt";

 LongPathToQuote( szApplicationPath, TRUE );

 szCmdLine = szApplicationPath + " " + szApplicationCmdLine;

 szDirectory  
 Specifies the working directory for the application. Note that if an empty string ("") is specified (and LAAW_OPTION_USE_SHELLEXECUTE is not specified), the function passes NULL to CreateProcess instead of an empty string.

 nShowWindow  
 Specifies the initial window state of the application as passed to CreateProcess in the wShowWindow parameter of the STARTUPINFO structure, or passed to ShellExecuteEx in the nShow parameter of the SHELLEXECUTEINFO structure (if LAAW_OPTION_USE_SHELLEXECUTE is specified). You can specify any documented value for the aforementioned functions; some values are predefined in windefs.h:
SW_FORCEMINIMIZE
SW_HIDE
SW_MAX
SW_MAXIMIZE
SW_MINIMIZE
SW_NORMAL
SW_RESTORE
SW_SHOW
SW_SHOWDEFAULT
SW_SHOWMAXIMIZED
SW_SHOWMINIMIZED
SW_SHOWMINNOACTIVE
SW_SHOWNA
SW_SHOWNOACTIVATE
SW_SHOWNORMAL

 nTimeOut  
 Specifies the nTimeOut value (in milliseconds) passed to the WaitForApplication function. Note that if you do not specify LAAW_OPTION_WAIT, the specified value is ignored.

 nOptions  
 Specifies various options, including whether the installation should wait for the launched application to terminate before continuing.

 Pass one of the following predefined constants in this parameter. You can combine these constants by using the bitwise OR operator ( | ), with the following exceptions: you cannot combine LAAW_OPTION_NOWAIT with LAAW_OPTION_WAIT, and you cannot combine LAAW_OPTION_HIDDEN, LAAW_OPTION_MINIMIZED, and LAAW_OPTION_MAXIMIZED.
LAAW_OPTION_USE_SHELLEXECUTE—Indicates that the function should call the Windows API function ShellExecuteEx instead of calling CreateProcess to launch the application.
LAAW_OPTION_NOWAIT—Passed through the function to WaitForApplication. Note that using this parameter is equivalent to calling the function LaunchApp.
LAAW_OPTION_WAIT—Passed through the function to WaitForApplication.
LAAW_OPTION_USE_CALLBACK—Passed through the function to WaitForApplication.
LAAW_OPTION_SET_BATCH_INSTALL—Specifies that the function internally sets BATCH_INSTALL to a non-zero value if it detects that the launched application causes a change that requires a reboot, such as updating the RunOnce key. The function attempts to determine this by checking the state of the system before launching the specified application and then comparing the current system state after launching the application (and waiting for the application to complete if LAAW_OPTION_WAIT is specified.) This flag can be used when launching third-party installations that do not return status information indicating that a reboot is needed.
LAAW_OPTION_SHOW_HOURGLASS—Specifies that the cursor changes to an hourglass while the launched application is running.
LAAW_OPTION_WAIT_INCL_CHILD—Passed through the function to WaitForApplication.

 nOptions (cont.)  
 This parameter also supports the following options, but they are no longer recommended:
LAAW_OPTION_HIDDEN—Specifies that the launched application's main window is initially hidden.
LAAW_OPTION_MINIMIZED—Specifies that the launched application's main window is initially minimized.
LAAW_OPTION_MAXIMIZED—Specifies that the launched application's main window is initially maximized.
LAAW_OPTION_NO_CHANGEDIRECTORY—This is obsolete. This parameter is ignored.
LAAW_OPTION_CHANGEDIRECTORY—Specifies that LaunchApplication should temporarily update the current directory of the installation to that of the application about to be launched. By default, LaunchApplication does not modify the current directory of the installation. Note that LaunchApplication resets the current directory of the installation back to the original value before LaunchApplication returns.
 

 Calling LaunchAppAndWait instead of LaunchApplication automatically includes this option.
LAAW_OPTION_FIXUP_PROGRAM —Specifies that LaunchApplication should call LongPathFromShortPath on szProgram in order to ensure that the call to CreateProcess or ShellExecuteEx works correctly. In most cases, this should not be needed.
 

 Calling LaunchAppAndWait instead of LaunchApplication automatically includes this option.

 Return Values

 LaunchApplication Return Values 
 Return Value  
 Description

 ISERR_SUCCESS  
 Indicates that the application was launched successfully.

 < ISERR_SUCCESS  
 Indicates that the application was not launched successfully.
 

 If the application cannot be launched, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the result of calling the Windows API function GetLastError after the CreateProcess or ShellExecuteEx call. If the function is successful and the LAAW_OPTION_WAIT option was specified, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the return code of the launched application.

 Additional Information
If you are not using LAAW_OPTION_USE_SHELLEXECUTE, update the LAAW_STARTUPINFO system variable before calling LaunchApplication to customize the behavior of the application. If you are LAAW_OPTION_USE_SHELLEXECUTE, customize the LAAW_SHELLEXECUTEINFO structure to customize the behavior of the application.
To obtain identification information about the launched process, use the LAAW_PROCESS_INFORMATION system variable or the LAAW_SHELLEXECUTEINFO system variable (if you are using LAAW_OPTION_USE_SHELLEXECUTE).
Note that if you are using LAAW_OPTION_USE_SHELLEXECUTE, the LAAW_PROCESS_INFORMATION is not used, except for the hProcess member. The hProcess member is updated to the process handle of the launched process (from the LAAW_SHELLEXECUTEINFO.hProcess member).

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值